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

Function TestTreeDoubleWildcard

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

Source from the content-addressed store, hash-verified

354}
355
356func TestTreeDoubleWildcard(t *testing.T) {
357 const panicMsg = "only one wildcard per path segment is allowed"
358
359 routes := [...]string{
360 "/:foo:bar",
361 "/:foo:bar/",
362 "/:foo*bar",
363 }
364
365 for _, route := range routes {
366 tree := &node{}
367 recv := catchPanic(func() {
368 tree.addRoute(route, nil)
369 })
370
371 if rs, ok := recv.(string); !ok || !strings.HasPrefix(rs, panicMsg) {
372 t.Fatalf(`"Expected panic "%s" for route '%s', got "%v"`, panicMsg, route, recv)
373 }
374 }
375}
376
377/*func TestTreeDuplicateWildcard(t *testing.T) {
378 tree := &node{}

Callers

nothing calls this directly

Calls 2

addRouteMethod · 0.95
catchPanicFunction · 0.85

Tested by

no test coverage detected