(t *testing.T)
| 154 | } |
| 155 | |
| 156 | func TestTreeWildcard(t *testing.T) { |
| 157 | tree := &node{} |
| 158 | |
| 159 | routes := [...]string{ |
| 160 | "/", |
| 161 | "/cmd/:tool/:sub", |
| 162 | "/cmd/:tool/", |
| 163 | "/src/*filepath", |
| 164 | "/search/", |
| 165 | "/search/:query", |
| 166 | "/user_:name", |
| 167 | "/user_:name/about", |
| 168 | "/files/:dir/*filepath", |
| 169 | "/doc/", |
| 170 | "/doc/go_faq.html", |
| 171 | "/doc/go1.html", |
| 172 | "/info/:user/public", |
| 173 | "/info/:user/project/:project", |
| 174 | } |
| 175 | for _, route := range routes { |
| 176 | tree.addRoute(route, fakeHandler(route)) |
| 177 | } |
| 178 | |
| 179 | //printChildren(tree, "") |
| 180 | |
| 181 | checkRequests(t, tree, testRequests{ |
| 182 | {"/", false, "/", nil}, |
| 183 | {"/cmd/test/", false, "/cmd/:tool/", Params{Param{"tool", "test"}}}, |
| 184 | {"/cmd/test", true, "", Params{Param{"tool", "test"}}}, |
| 185 | {"/cmd/test/3", false, "/cmd/:tool/:sub", Params{Param{"tool", "test"}, Param{"sub", "3"}}}, |
| 186 | {"/src/", false, "/src/*filepath", Params{Param{"filepath", "/"}}}, |
| 187 | {"/src/some/file.png", false, "/src/*filepath", Params{Param{"filepath", "/some/file.png"}}}, |
| 188 | {"/search/", false, "/search/", nil}, |
| 189 | {"/search/someth!ng+in+ünìcodé", false, "/search/:query", Params{Param{"query", "someth!ng+in+ünìcodé"}}}, |
| 190 | {"/search/someth!ng+in+ünìcodé/", true, "", Params{Param{"query", "someth!ng+in+ünìcodé"}}}, |
| 191 | {"/user_gopher", false, "/user_:name", Params{Param{"name", "gopher"}}}, |
| 192 | {"/user_gopher/about", false, "/user_:name/about", Params{Param{"name", "gopher"}}}, |
| 193 | {"/files/js/inc/framework.js", false, "/files/:dir/*filepath", Params{Param{"dir", "js"}, Param{"filepath", "/inc/framework.js"}}}, |
| 194 | {"/info/gordon/public", false, "/info/:user/public", Params{Param{"user", "gordon"}}}, |
| 195 | {"/info/gordon/project/go", false, "/info/:user/project/:project", Params{Param{"user", "gordon"}, Param{"project", "go"}}}, |
| 196 | }) |
| 197 | |
| 198 | checkPriorities(t, tree) |
| 199 | checkMaxParams(t, tree) |
| 200 | } |
| 201 | |
| 202 | func catchPanic(testFunc func()) (recv interface{}) { |
| 203 | defer func() { |
nothing calls this directly
no test coverage detected