Added tests for FindString

master
Aadhavan Srinivasan 2 days ago
parent 47ec95f7bb
commit fb46ed62d9

@ -204,6 +204,28 @@ func TestFindAllMatches(t *testing.T) {
}
}
func TestFindString(t *testing.T) {
for _, test := range reTests {
t.Run(test.re+" "+test.str, func(t *testing.T) {
regComp, err := Compile(test.re)
if err != nil {
panic(err)
}
foundString := FindString(regComp, 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 != foundString {
t.Errorf("Wanted %v Got %v\n", expectedString, foundString)
}
}
})
}
}
func TestFindAllGroups(t *testing.T) {
for _, test := range groupTests {
t.Run(test.re+" "+test.str, func(t *testing.T) {

Loading…
Cancel
Save