mirror of
https://github.com/gin-gonic/gin.git
synced 2026-11-26 21:53:44 +08:00
fix(tree): ensure pooled skippedNodes accommodates late registered routes
Signed-off-by: AdamMagued <adamismailmageud@gmail.com>
This commit is contained in:
parent
0f09c3a9b4
commit
8d2690475b
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