TestFindStringSubmatch_DotPlusCapture_StdlibCompatibility verifies that FindStringSubmatch matches stdlib regexp behavior for .+ patterns.
(t *testing.T)
| 914 | // TestFindStringSubmatch_DotPlusCapture_StdlibCompatibility verifies that |
| 915 | // FindStringSubmatch matches stdlib regexp behavior for .+ patterns. |
| 916 | func TestFindStringSubmatch_DotPlusCapture_StdlibCompatibility(t *testing.T) { |
| 917 | patterns := []string{ |
| 918 | `^(.+)-(\d+)$`, |
| 919 | `^(.+?)-(\d+)$`, |
| 920 | `^(.*)x(\d+)$`, |
| 921 | `(.+)-(\d+)`, |
| 922 | `^(.+):(\d+)$`, |
| 923 | `^(.+)-(.+)-(\d+)$`, |
| 924 | `^(.+)-(\d.*)$`, |
| 925 | } |
| 926 | |
| 927 | inputs := []string{ |
| 928 | "hello-123", |
| 929 | "a-b-c-456", |
| 930 | "abcx789", |
| 931 | "test-999", |
| 932 | "host:8080", |
| 933 | "a-b-123", |
| 934 | "pkg-1.2.3", |
| 935 | } |
| 936 | |
| 937 | for _, pattern := range patterns { |
| 938 | stdRe := regexp.MustCompile(pattern) |
| 939 | cgRe := MustCompile(pattern) |
| 940 | |
| 941 | for _, input := range inputs { |
| 942 | stdMatch := stdRe.FindStringSubmatch(input) |
| 943 | cgMatch := cgRe.FindStringSubmatch(input) |
| 944 | |
| 945 | if !reflect.DeepEqual(stdMatch, cgMatch) { |
| 946 | t.Errorf("Pattern %q, Input %q:\n stdlib: %v\n coregex: %v", |
| 947 | pattern, input, stdMatch, cgMatch) |
| 948 | } |
| 949 | } |
| 950 | } |
| 951 | } |
| 952 | |
| 953 | // TestFindSubmatchIndex_DotPlusCapture tests capture group indices with .+ patterns. |
| 954 | func TestFindSubmatchIndex_DotPlusCapture(t *testing.T) { |
nothing calls this directly
no test coverage detected