Created
December 11, 2020 09:09
-
-
Save ayzu/cf5e6df48a95a83147757559696412d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"reflect" | |
"testing" | |
) | |
func TestWordsConcatenation(t *testing.T) { | |
type args struct { | |
arr string | |
words []string | |
} | |
tests := []struct { | |
name string | |
args args | |
want []int | |
}{ | |
{ | |
name: "", | |
args: args{ | |
arr: "a", | |
words: []string{"a"}, | |
}, | |
want: []int{0}, | |
}, | |
{ | |
name: "", | |
args: args{ | |
arr: "a", | |
words: []string{"a", "b"}, | |
}, | |
want: nil, | |
}, | |
{ | |
name: "", | |
args: args{ | |
arr: "cab", | |
words: []string{"b", "a"}, | |
}, | |
want: []int{1}, | |
}, | |
{ | |
name: "", | |
args: args{ | |
arr: "catfoxcat", | |
words: []string{"cat", "fox"}, | |
}, | |
want: []int{0, 3}, | |
}, | |
{ | |
name: "", | |
args: args{ | |
arr: "catcatfoxfox", | |
words: []string{"cat", "fox"}, | |
}, | |
want: []int{3}, | |
}, | |
{ | |
name: "", | |
args: args{ | |
arr: "caa", | |
words: []string{"aa"}, | |
}, | |
want: []int{1}, | |
}, | |
{ | |
name: "", | |
args: args{ | |
arr: "caab", | |
words: []string{"aa"}, | |
}, | |
want: []int{1}, | |
}, | |
} | |
for _, tt := range tests { | |
t.Run( | |
tt.name, func(t *testing.T) { | |
if got := WordsConcatenation(tt.args.arr, tt.args.words); !reflect.DeepEqual(got, tt.want) { | |
t.Errorf("WordsConcatenation() = %v, want %v", got, tt.want) | |
} | |
}, | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment