-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_test.go
More file actions
executable file
·61 lines (54 loc) · 947 Bytes
/
array_test.go
File metadata and controls
executable file
·61 lines (54 loc) · 947 Bytes
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
// Package util
package utils
import "testing"
func TestInArray(t *testing.T) {
t.Parallel()
testCase := []struct {
Case int
Value interface{}
Collection interface{}
Valid bool
}{
{
Case: 1,
Value: "test",
Collection: []string{
"test",
"test123",
},
Valid: true,
},
{
Case: 2,
Value: 2,
Collection: []string{
"test",
"test123",
},
Valid: false,
},
{
Case: 3,
Value: int64(3),
Collection: []int64{1, 2, 3},
Valid: true,
},
{
Case: 4,
Value: "case-4",
Collection: map[string]string{
"case-4": "case-4",
},
Valid: false,
},
}
for _, v := range testCase {
valid := InArray(v.Value, v.Collection)
if valid == v.Valid {
t.Logf("scenario #%v exptected %v, got %v", v.Case, v.Valid, valid)
}
if valid != v.Valid {
t.Errorf("scenario #%v exptected %v, got %v", v.Case, v.Valid, valid)
}
}
}