| 6 | ) |
| 7 | |
| 8 | func TestKmp(t *testing.T) { |
| 9 | type args struct { |
| 10 | word string |
| 11 | text string |
| 12 | patternTable []int |
| 13 | } |
| 14 | tests := []struct { |
| 15 | name string |
| 16 | args args |
| 17 | want []int |
| 18 | }{ |
| 19 | { |
| 20 | name: "test1", |
| 21 | args: args{ |
| 22 | word: "ab", |
| 23 | text: "ababacaab", |
| 24 | patternTable: table("ababacaab"), |
| 25 | }, |
| 26 | want: []int{0, 2, 7}, |
| 27 | }, |
| 28 | } |
| 29 | for _, tt := range tests { |
| 30 | t.Run(tt.name, func(t *testing.T) { |
| 31 | if got := Kmp(tt.args.word, tt.args.text, tt.args.patternTable); !reflect.DeepEqual(got, tt.want) { |
| 32 | t.Errorf("Kmp() = %v, want %v", got, tt.want) |
| 33 | } |
| 34 | }) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | func TestTable(t *testing.T) { |
| 39 | type args struct { |