mirror of
https://github.com/gin-gonic/gin.git
synced 2026-11-23 11:33:37 +08:00
Merge 8d2690475b7283426794eca186d0f23d54e97c9c into 0f09c3a9b4626d9fe9979cf4d0521d6ae32ab646
This commit is contained in:
commit
973c2115c2
22
tree_test.go
22
tree_test.go
@ -1111,3 +1111,25 @@ func TestTreeFindCaseInsensitivePathWildcardParamAndStaticChild(t *testing.T) {
|
||||
t.Errorf("Wrong result for '/prefix/something': %s", string(out))
|
||||
}
|
||||
}
|
||||
|
||||
func TestTreeSkippedNodesDynamicGrowth(t *testing.T) {
|
||||
tree := &node{}
|
||||
routes := [...]string{
|
||||
"/x/y/z/w",
|
||||
"/x/y/:id/w",
|
||||
"/x/:id/z/w",
|
||||
"/:id/y/z/w",
|
||||
}
|
||||
for _, route := range routes {
|
||||
tree.addRoute(route, fakeHandler(route))
|
||||
}
|
||||
|
||||
skippedNodes := make([]skippedNode, 0, 1)
|
||||
val := tree.getValue("/x/y/z/w/extra", nil, &skippedNodes, false)
|
||||
if val.handlers != nil {
|
||||
t.Fatalf("expected nil handlers, got %v", val.handlers)
|
||||
}
|
||||
if cap(skippedNodes) <= 1 {
|
||||
t.Fatalf("expected skippedNodes capacity to grow beyond 1, got %d", cap(skippedNodes))
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user