formatted

This commit is contained in:
Agnes-George1 2025-11-24 18:10:08 +05:30
parent 9b3d7f632a
commit a9b0085e40

View File

@ -521,16 +521,16 @@ func TestTreeChildConflict(t *testing.T) {
func TestWildcardConflictWithStringsCut(t *testing.T) {
// Test the strings.Cut usage in wildcard conflict detection (line 258 in tree.go)
tree := &node{}
// Add a route with a wildcard parameter
tree.addRoute("/user/:name", fakeHandler("/user/:name"))
// Try to add a conflicting route that will trigger the strings.Cut path
// This should panic with a wildcard conflict
recv := catchPanic(func() {
tree.addRoute("/user/:id/profile", fakeHandler("/user/:id/profile"))
})
if recv == nil {
t.Error("Expected panic for wildcard conflict, but got none")
}
@ -539,28 +539,28 @@ func TestWildcardConflictWithStringsCut(t *testing.T) {
func TestCatchAllConflictWithStringsCut(t *testing.T) {
// Test the strings.Cut usage in catch-all conflict detection (line 382 in tree.go)
tree := &node{}
// Add a route with a path segment
tree.addRoute("/files/list", fakeHandler("/files/list"))
// Try to add a catch-all route that conflicts
// This should panic with a catch-all conflict
recv := catchPanic(func() {
tree.addRoute("/files/*filepath", fakeHandler("/files/*filepath"))
})
if recv == nil {
t.Error("Expected panic for catch-all conflict, but got none")
}
// Also test with an empty children case to cover line 382 when len(n.children) == 0
tree2 := &node{}
tree2.addRoute("/docs/", fakeHandler("/docs/"))
recv2 := catchPanic(func() {
tree2.addRoute("/docs/*page", fakeHandler("/docs/*page"))
})
if recv2 == nil {
t.Error("Expected panic for catch-all conflict with empty children, but got none")
}