MCPcopy Create free account
hub / github.com/coregx/coregex / TestFindStringSubmatch_DotPlusCapture_StdlibCompatibility

Function TestFindStringSubmatch_DotPlusCapture_StdlibCompatibility

regex_test.go:916–951  ·  view source on GitHub ↗

TestFindStringSubmatch_DotPlusCapture_StdlibCompatibility verifies that FindStringSubmatch matches stdlib regexp behavior for .+ patterns.

(t *testing.T)

Source from the content-addressed store, hash-verified

914// TestFindStringSubmatch_DotPlusCapture_StdlibCompatibility verifies that
915// FindStringSubmatch matches stdlib regexp behavior for .+ patterns.
916func 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.
954func TestFindSubmatchIndex_DotPlusCapture(t *testing.T) {

Callers

nothing calls this directly

Calls 2

MustCompileFunction · 0.85
FindStringSubmatchMethod · 0.80

Tested by

no test coverage detected