MCPcopy
hub / github.com/julienschmidt/httprouter / TestTreeAddAndGet

Function TestTreeAddAndGet

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

Source from the content-addressed store, hash-verified

114}
115
116func TestTreeAddAndGet(t *testing.T) {
117 tree := &node{}
118
119 routes := [...]string{
120 "/hi",
121 "/contact",
122 "/co",
123 "/c",
124 "/a",
125 "/ab",
126 "/doc/",
127 "/doc/go_faq.html",
128 "/doc/go1.html",
129 "/α",
130 "/β",
131 }
132 for _, route := range routes {
133 tree.addRoute(route, fakeHandler(route))
134 }
135
136 //printChildren(tree, "")
137
138 checkRequests(t, tree, testRequests{
139 {"/a", false, "/a", nil},
140 {"/", true, "", nil},
141 {"/hi", false, "/hi", nil},
142 {"/contact", false, "/contact", nil},
143 {"/co", false, "/co", nil},
144 {"/con", true, "", nil}, // key mismatch
145 {"/cona", true, "", nil}, // key mismatch
146 {"/no", true, "", nil}, // no matching child
147 {"/ab", false, "/ab", nil},
148 {"/α", false, "/α", nil},
149 {"/β", false, "/β", nil},
150 })
151
152 checkPriorities(t, tree)
153 checkMaxParams(t, tree)
154}
155
156func TestTreeWildcard(t *testing.T) {
157 tree := &node{}

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected