Home / Function/ TestTreeFindCaseInsensitivePath() — gin Function Reference

TestTreeFindCaseInsensitivePath() — gin Function Reference

Architecture documentation for the TestTreeFindCaseInsensitivePath() function in tree_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  0e28c102_068f_5f8a_3b47_583bb57475d4["TestTreeFindCaseInsensitivePath()"]
  95642d64_cc2a_14f0_a93c_52464b2a60b9["tree_test.go"]
  0e28c102_068f_5f8a_3b47_583bb57475d4 -->|defined in| 95642d64_cc2a_14f0_a93c_52464b2a60b9
  e88fa484_0d98_1d59_f804_c3948a6745fe["catchPanic()"]
  0e28c102_068f_5f8a_3b47_583bb57475d4 -->|calls| e88fa484_0d98_1d59_f804_c3948a6745fe
  93c1c821_291f_3e71_2ae0_563c40ff3ee5["fakeHandler()"]
  0e28c102_068f_5f8a_3b47_583bb57475d4 -->|calls| 93c1c821_291f_3e71_2ae0_563c40ff3ee5
  style 0e28c102_068f_5f8a_3b47_583bb57475d4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tree_test.go lines 714–872

func TestTreeFindCaseInsensitivePath(t *testing.T) {
	tree := &node{}

	longPath := "/l" + strings.Repeat("o", 128) + "ng"
	lOngPath := "/l" + strings.Repeat("O", 128) + "ng/"

	routes := [...]string{
		"/hi",
		"/b/",
		"/ABC/",
		"/search/:query",
		"/cmd/:tool/",
		"/src/*filepath",
		"/x",
		"/x/y",
		"/y/",
		"/y/z",
		"/0/:id",
		"/0/:id/1",
		"/1/:id/",
		"/1/:id/2",
		"/aa",
		"/a/",
		"/doc",
		"/doc/go_faq.html",
		"/doc/go1.html",
		"/doc/go/away",
		"/no/a",
		"/no/b",
		"/Π",
		"/u/apfêl/",
		"/u/äpfêl/",
		"/u/öpfêl",
		"/v/Äpfêl/",
		"/v/Öpfêl",
		"/w/♬",  // 3 byte
		"/w/♭/", // 3 byte, last byte differs
		"/w/𠜎",  // 4 byte
		"/w/𠜏/", // 4 byte
		longPath,
	}

	for _, route := range routes {
		recv := catchPanic(func() {
			tree.addRoute(route, fakeHandler(route))
		})
		if recv != nil {
			t.Fatalf("panic inserting route '%s': %v", route, recv)
		}
	}

	// Check out == in for all registered routes
	// With fixTrailingSlash = true
	for _, route := range routes {
		out, found := tree.findCaseInsensitivePath(route, true)
		if !found {
			t.Errorf("Route '%s' not found!", route)
		} else if string(out) != route {
			t.Errorf("Wrong result for route '%s': %s", route, string(out))
		}
	}
	// With fixTrailingSlash = false
	for _, route := range routes {
		out, found := tree.findCaseInsensitivePath(route, false)
		if !found {
			t.Errorf("Route '%s' not found!", route)
		} else if string(out) != route {
			t.Errorf("Wrong result for route '%s': %s", route, string(out))
		}
	}

	tests := []struct {
		in    string
		out   string
		found bool
		slash bool
	}{
		{"/HI", "/hi", true, false},
		{"/HI/", "/hi", true, true},
		{"/B", "/b/", true, true},
		{"/B/", "/b/", true, false},

Domain

Subdomains

Defined In

Frequently Asked Questions

What does TestTreeFindCaseInsensitivePath() do?
TestTreeFindCaseInsensitivePath() is a function in the gin codebase, defined in tree_test.go.
Where is TestTreeFindCaseInsensitivePath() defined?
TestTreeFindCaseInsensitivePath() is defined in tree_test.go at line 714.
What does TestTreeFindCaseInsensitivePath() call?
TestTreeFindCaseInsensitivePath() calls 2 function(s): catchPanic, fakeHandler.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free