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

Function TestWildcardInvalidSlash

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

Source from the content-addressed store, hash-verified

995}
996
997func TestWildcardInvalidSlash(t *testing.T) {
998 const panicMsgPrefix = "no / before catch-all in path"
999
1000 routes := map[string]bool{
1001 "/foo/bar": true,
1002 "/foo/x*zy": false,
1003 "/foo/b*r": false,
1004 }
1005
1006 for route, valid := range routes {
1007 tree := &node{}
1008 recv := catchPanic(func() {
1009 tree.addRoute(route, nil)
1010 })
1011
1012 if recv == nil != valid {
1013 t.Fatalf("%s should be %t but got %v", route, valid, recv)
1014 }
1015
1016 if rs, ok := recv.(string); recv != nil && (!ok || !strings.HasPrefix(rs, panicMsgPrefix)) {
1017 t.Fatalf(`"Expected panic "%s" for route '%s', got "%v"`, panicMsgPrefix, route, recv)
1018 }
1019 }
1020}
1021
1022func TestTreeFindCaseInsensitivePathWithMultipleChildrenAndWildcard(t *testing.T) {
1023 tree := &node{}

Callers

nothing calls this directly

Calls 2

addRouteMethod · 0.95
catchPanicFunction · 0.85

Tested by

no test coverage detected