MCPcopy
hub / github.com/julienschmidt/httprouter / TestTreeFindCaseInsensitivePath

Function TestTreeFindCaseInsensitivePath

tree_test.go:489–642  ·  tree_test.go::TestTreeFindCaseInsensitivePath
(t *testing.T)

Source from the content-addressed store, hash-verified

487}
488
489func TestTreeFindCaseInsensitivePath(t *testing.T) {
490 tree := &node{}
491
492 routes := [...]string{
493 "/hi",
494 "/b/",
495 "/ABC/",
496 "/search/:query",
497 "/cmd/:tool/",
498 "/src/*filepath",
499 "/x",
500 "/x/y",
501 "/y/",
502 "/y/z",
503 "/0/:id",
504 "/0/:id/1",
505 "/1/:id/",
506 "/1/:id/2",
507 "/aa",
508 "/a/",
509 "/doc",
510 "/doc/go_faq.html",
511 "/doc/go1.html",
512 "/doc/go/away",
513 "/no/a",
514 "/no/b",
515 "/Π",
516 "/u/apfêl/",
517 "/u/äpfêl/",
518 "/u/öpfêl",
519 "/v/Äpfêl/",
520 "/v/Öpfêl",
521 "/w/♬", // 3 byte
522 "/w/♭/", // 3 byte, last byte differs
523 "/w/𠜎", // 4 byte
524 "/w/𠜏/", // 4 byte
525 }
526
527 for _, route := range routes {
528 recv := catchPanic(func() {
529 tree.addRoute(route, fakeHandler(route))
530 })
531 if recv != nil {
532 t.Fatalf("panic inserting route '%s': %v", route, recv)
533 }
534 }
535
536 // Check out == in for all registered routes
537 // With fixTrailingSlash = true
538 for _, route := range routes {
539 out, found := tree.findCaseInsensitivePath(route, true)
540 if !found {
541 t.Errorf("Route '%s' not found!", route)
542 } else if string(out) != route {
543 t.Errorf("Wrong result for route '%s': %s", route, string(out))
544 }
545 }
546 // With fixTrailingSlash = false

Callers

nothing calls this directly

Calls 4

addRouteMethod · 0.95
catchPanicFunction · 0.85
fakeHandlerFunction · 0.85

Tested by

no test coverage detected