(t *testing.T)
| 8 | import "fmt" |
| 9 | |
| 10 | func TestLHorspool(t *testing.T) { |
| 11 | testCases := []struct { |
| 12 | input string |
| 13 | pattern string |
| 14 | expected int |
| 15 | }{ |
| 16 | {"aaaaXaaa", "X", 4}, |
| 17 | {"aaaaXXaa", "XX", 4}, |
| 18 | {"Xaaab", "X", 0}, |
| 19 | {"XYaab", "XY", 0}, |
| 20 | {"abcefghXYZ", "XYZ", 7}, |
| 21 | {"abcefgh€YZ⌘", "€YZ", 7}, |
| 22 | {"⌘bcefgh€YZ⌘", "€YZ", 7}, |
| 23 | {"abc", "abc", 0}, |
| 24 | {"", "", 0}, |
| 25 | {"a", "", 0}, |
| 26 | {"a", "a", 0}, |
| 27 | {"aa", "a", 0}, |
| 28 | {"aa", "aa", 0}, |
| 29 | } |
| 30 | for _, tc := range testCases { |
| 31 | t.Run(fmt.Sprint("test with ", tc.input, " ", tc.pattern), func(t *testing.T) { |
| 32 | result, curError := Horspool(tc.input, tc.pattern) |
| 33 | if curError != nil { |
| 34 | t.Fatalf("Got unexpected error") |
| 35 | } |
| 36 | if tc.expected != result { |
| 37 | t.Fatalf("expected %d, got %d", tc.expected, result) |
| 38 | } |
| 39 | }) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | func TestLHorspoolNotExisintPattern(t *testing.T) { |
| 44 | testCases := []struct { |
nothing calls this directly
no test coverage detected