MCPcopy
hub / github.com/gofiber/fiber / Benchmark_RoutePatternMatch

Function Benchmark_RoutePatternMatch

path_test.go:415–442  ·  view source on GitHub ↗
(t *testing.B)

Source from the content-addressed store, hash-verified

413}
414
415func Benchmark_RoutePatternMatch(t *testing.B) {
416 benchCaseFn := func(testCollection routeCaseCollection) {
417 for _, c := range testCollection.testCases {
418 // skip all cases for partial checks
419 if c.partialCheck {
420 continue
421 }
422 var matchRes bool
423 state := "match"
424 if !c.match {
425 state = "not match"
426 }
427 t.Run(testCollection.pattern+"_"+state+"_"+c.url, func(b *testing.B) {
428 for b.Loop() {
429 if match := RoutePatternMatch(c.url, testCollection.pattern); match {
430 // Get testCases from the original path
431 matchRes = true
432 }
433 }
434 require.Equal(t, c.match, matchRes, "route: '%s', url: '%s'", testCollection.pattern, c.url)
435 })
436 }
437 }
438
439 for _, testCollection := range benchmarkCases {
440 benchCaseFn(testCollection)
441 }
442}
443
444func Test_Route_TooManyParams_Panic(t *testing.T) {
445 t.Parallel()

Callers

nothing calls this directly

Calls 1

RoutePatternMatchFunction · 0.85

Tested by

no test coverage detected