Test_RoutePatternMatch_WithRegex verifies RoutePatternMatch works with regex constraints
(t *testing.T)
| 645 | |
| 646 | // Test_RoutePatternMatch_WithRegex verifies RoutePatternMatch works with regex constraints |
| 647 | func Test_RoutePatternMatch_WithRegex(t *testing.T) { |
| 648 | t.Parallel() |
| 649 | |
| 650 | // Test with default handler |
| 651 | require.True(t, RoutePatternMatch("/api/123", "/api/:id<regex(\\d+)>")) |
| 652 | require.False(t, RoutePatternMatch("/api/abc", "/api/:id<regex(\\d+)>")) |
| 653 | |
| 654 | // Test with custom config |
| 655 | var lastPattern string |
| 656 | var compileCalled bool |
| 657 | require.True(t, RoutePatternMatch("/api/123", "/api/:id<regex(\\d+)>", Config{ |
| 658 | RegexHandler: mockRegexHandler(&lastPattern, &compileCalled), |
| 659 | })) |
| 660 | require.True(t, compileCalled, "RegexHandler should have been called") |
| 661 | } |
| 662 | |
| 663 | // Test_RegexHandler_NilDefaultsToStdlib verifies that nil RegexHandler defaults to stdlib |
| 664 | func Test_RegexHandler_NilDefaultsToStdlib(t *testing.T) { |
nothing calls this directly
no test coverage detected