-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram_test.go
42 lines (37 loc) · 1.01 KB
/
program_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"reflect"
"strconv"
"testing"
)
type testInputList struct {
inputList []string
expectedList [][]string
}
var testInputLists = []testInputList{
{
inputList: []string{"cerg ", "sample", " cegr", "", " ", "🚲ab", "ba🚲", "cgre", "cger", "samlep", "samepl", "samelp", "sapmle", "anurag", "gnuraA"},
expectedList: [][]string{
{"", ""},
{"anurag", "gnuraa"},
{"ba🚲", "🚲ab"},
{"samelp", "samepl", "samlep", "sample", "sapmle"},
{"cegr", "cerg", "cger", "cgre"},
},
},
}
func TestListAllAnagramsInSlice(t *testing.T) {
for index, test := range testInputLists {
testName := "Test" + strconv.Itoa(index)
t.Run(testName, func(t *testing.T) {
if result := ListAllAnagramsInSlice(test.inputList); !reflect.DeepEqual(result, test.expectedList) {
t.Errorf("expected:\n\t%#+v\ngot\n\t%#+v", test.expectedList, result)
}
})
}
}
func BenchmarkListAllAnagramsInSlice(b *testing.B) {
for i := 0; i < b.N; i++ {
ListAllAnagramsInSlice(testInputLists[0].inputList)
}
}