From 94c8044eb7b525b1a2045aea1efba95100e85a01 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Tue, 28 Jan 2025 11:42:53 -0500 Subject: [PATCH] Running all tests case-insensitive with the same match indices wasn't a good idea --- re_test.go | 67 ------------------------------------------------------ 1 file changed, 67 deletions(-) diff --git a/re_test.go b/re_test.go index 3f0d09e..ba26fe6 100644 --- a/re_test.go +++ b/re_test.go @@ -427,27 +427,6 @@ func TestFindAllMatches(t *testing.T) { } }) } - fmt.Printf("----------------CASE INSENSITIVE MATCHING----------------") - // Case-insensitive run, with test string case-swapped - for _, test := range reTests { - t.Run(test.re+" "+swapCase(test.str), func(t *testing.T) { - regComp, err := Compile(test.re, append(test.flags, RE_CASE_INSENSITIVE)...) - if err != nil { - if test.result != nil { - panic(fmt.Errorf("Test Error: %v", err)) - } - } else { - matchIndices := FindAllMatches(regComp, swapCase(test.str)) - zeroGroups := make([]Group, len(matchIndices)) - for i, m := range matchIndices { - zeroGroups[i] = m[0] - } - if !slices.Equal(test.result, zeroGroups) { - t.Errorf("Wanted %v Got %v\n", test.result, zeroGroups) - } - } - }) - } } func TestFindString(t *testing.T) { @@ -473,30 +452,6 @@ func TestFindString(t *testing.T) { } }) } - fmt.Printf("----------------CASE INSENSITIVE MATCHING----------------") - // Case-insensitive run, with test string case-swapped - for _, test := range reTests { - t.Run(test.re+" "+swapCase(test.str), func(t *testing.T) { - regComp, err := Compile(test.re, append(test.flags, RE_CASE_INSENSITIVE)...) - if err != nil { - if test.result != nil { - panic(err) - } - } else { - foundString := FindString(regComp, swapCase(test.str)) - if len(test.result) == 0 { - if foundString != "" { - t.Errorf("Expected no match got %v\n", foundString) - } - } else { - expectedString := test.str[test.result[0].startIdx:test.result[0].endIdx] - if foundString != expectedString { - t.Errorf("Wanted %v Got %v\n", expectedString, foundString) - } - } - } - }) - } } func TestFindAllGroups(t *testing.T) { @@ -520,26 +475,4 @@ func TestFindAllGroups(t *testing.T) { } }) } - fmt.Printf("----------------CASE INSENSITIVE MATCHING----------------") - // Case-insensitive run, with test string case-swapped - for _, test := range groupTests { - t.Run(test.re+" "+swapCase(test.str), func(t *testing.T) { - regComp, err := Compile(test.re, append(test.flags, RE_CASE_INSENSITIVE)...) - if err != nil { - if test.result != nil { - panic(err) - } - } - matchIndices := FindAllMatches(regComp, swapCase(test.str)) - for i := range matchIndices { - for j := range matchIndices[i] { - if matchIndices[i][j].isValid() { - if test.result[i][j] != matchIndices[i][j] { - t.Errorf("Wanted %v Got %v\n", test.result, matchIndices) - } - } - } - } - }) - } }