MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestKmp

Function TestKmp

strings/kmp/kmp_test.go:8–36  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func 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
38func TestTable(t *testing.T) {
39 type args struct {

Callers

nothing calls this directly

Calls 2

tableFunction · 0.85
KmpFunction · 0.85

Tested by

no test coverage detected