MCPcopy
hub / github.com/gin-gonic/gin / TestTreeAddAndGet

Function TestTreeAddAndGet

tree_test.go:101–136  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

99}
100
101func TestTreeAddAndGet(t *testing.T) {
102 tree := &node{}
103
104 routes := [...]string{
105 "/hi",
106 "/contact",
107 "/co",
108 "/c",
109 "/a",
110 "/ab",
111 "/doc/",
112 "/doc/go_faq.html",
113 "/doc/go1.html",
114 "/α",
115 "/β",
116 }
117 for _, route := range routes {
118 tree.addRoute(route, fakeHandler(route))
119 }
120
121 checkRequests(t, tree, testRequests{
122 {"/a", false, "/a", nil},
123 {"/", true, "", nil},
124 {"/hi", false, "/hi", nil},
125 {"/contact", false, "/contact", nil},
126 {"/co", false, "/co", nil},
127 {"/con", true, "", nil}, // key mismatch
128 {"/cona", true, "", nil}, // key mismatch
129 {"/no", true, "", nil}, // no matching child
130 {"/ab", false, "/ab", nil},
131 {"/α", false, "/α", nil},
132 {"/β", false, "/β", nil},
133 })
134
135 checkPriorities(t, tree)
136}
137
138func TestTreeWildcard(t *testing.T) {
139 tree := &node{}

Callers

nothing calls this directly

Calls 4

addRouteMethod · 0.95
fakeHandlerFunction · 0.85
checkRequestsFunction · 0.85
checkPrioritiesFunction · 0.85

Tested by

no test coverage detected