-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_test.go
113 lines (110 loc) · 2.66 KB
/
utils_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package sock_pair_in_golang
import (
"reflect"
"testing"
)
func TestGenerateSocks_pairs(t *testing.T) {
type args struct {
colors []string
patterns []string
numDuplicates int
}
tests := []struct {
name string
args args
want Socks
}{
{
"3 colors, 3 patterns, 1 pair of each style",
args{
[]string{"red", "blue", "green"},
[]string{"plain", "checkered", "herringbone"},
1,
},
Socks{
Sock{"red", "plain", true},
Sock{"red", "plain", false},
Sock{"blue", "plain", true},
Sock{"blue", "plain", false},
Sock{"green", "plain", true},
Sock{"green", "plain", false},
Sock{"red", "checkered", true},
Sock{"red", "checkered", false},
Sock{"blue", "checkered", true},
Sock{"blue", "checkered", false},
Sock{"green", "checkered", true},
Sock{"green", "checkered", false},
Sock{"red", "herringbone", true},
Sock{"red", "herringbone", false},
Sock{"blue", "herringbone", true},
Sock{"blue", "herringbone", false},
Sock{"green", "herringbone", true},
Sock{"green", "herringbone", false},
},
},
{
"3 colors, 3 patterns, 0 pairs",
args{
[]string{"red", "blue", "green"},
[]string{"plain", "checkered", "herringbone"},
0,
},
make(Socks, 0),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GenerateSocks(tt.args.colors, tt.args.patterns, tt.args.numDuplicates, false); !reflect.DeepEqual(got, tt.want) {
t.Errorf("GenerateSocks() = %v, want %v", got, tt.want)
}
})
}
}
func TestGenerateSocks_singles(t *testing.T) {
type args struct {
colors []string
patterns []string
numDuplicates int
}
tests := []struct {
name string
args args
want Socks
}{
{
"3 colors, 3 patterns, 1 of each style",
args{
[]string{"red", "blue", "green"},
[]string{"plain", "checkered", "herringbone"},
1,
},
Socks{
Sock{"red", "plain", true},
Sock{"blue", "plain", true},
Sock{"green", "plain", true},
Sock{"red", "checkered", true},
Sock{"blue", "checkered", true},
Sock{"green", "checkered", true},
Sock{"red", "herringbone", true},
Sock{"blue", "herringbone", true},
Sock{"green", "herringbone", true},
},
},
{
"3 colors, 3 patterns, 0 of each style",
args{
[]string{"red", "blue", "green"},
[]string{"plain", "checkered", "herringbone"},
0,
},
make(Socks, 0),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GenerateSocks(tt.args.colors, tt.args.patterns, tt.args.numDuplicates, true); !reflect.DeepEqual(got, tt.want) {
t.Errorf("GenerateSocks() = %v, want %v", got, tt.want)
}
})
}
}