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

Function TestTreeFindCaseInsensitivePath

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

Source from the content-addressed store, hash-verified

712}
713
714func TestTreeFindCaseInsensitivePath(t *testing.T) {
715 tree := &node{}
716
717 longPath := "/l" + strings.Repeat("o", 128) + "ng"
718 lOngPath := "/l" + strings.Repeat("O", 128) + "ng/"
719
720 routes := [...]string{
721 "/hi",
722 "/b/",
723 "/ABC/",
724 "/search/:query",
725 "/cmd/:tool/",
726 "/src/*filepath",
727 "/x",
728 "/x/y",
729 "/y/",
730 "/y/z",
731 "/0/:id",
732 "/0/:id/1",
733 "/1/:id/",
734 "/1/:id/2",
735 "/aa",
736 "/a/",
737 "/doc",
738 "/doc/go_faq.html",
739 "/doc/go1.html",
740 "/doc/go/away",
741 "/no/a",
742 "/no/b",
743 "/Π",
744 "/u/apfêl/",
745 "/u/äpfêl/",
746 "/u/öpfêl",
747 "/v/Äpfêl/",
748 "/v/Öpfêl",
749 "/w/♬", // 3 byte
750 "/w/♭/", // 3 byte, last byte differs
751 "/w/𠜎", // 4 byte
752 "/w/𠜏/", // 4 byte
753 longPath,
754 }
755
756 for _, route := range routes {
757 recv := catchPanic(func() {
758 tree.addRoute(route, fakeHandler(route))
759 })
760 if recv != nil {
761 t.Fatalf("panic inserting route '%s': %v", route, recv)
762 }
763 }
764
765 // Check out == in for all registered routes
766 // With fixTrailingSlash = true
767 for _, route := range routes {
768 out, found := tree.findCaseInsensitivePath(route, true)
769 if !found {
770 t.Errorf("Route '%s' not found!", route)
771 } else if string(out) != route {

Callers

nothing calls this directly

Calls 4

addRouteMethod · 0.95
catchPanicFunction · 0.85
fakeHandlerFunction · 0.85

Tested by

no test coverage detected