-
Notifications
You must be signed in to change notification settings - Fork 0
/
type_test.go
64 lines (60 loc) · 1.48 KB
/
type_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
package ep_test
import (
"github.com/panoplyio/ep"
"github.com/stretchr/testify/require"
"testing"
)
func TestAreEqualTypes(t *testing.T) {
cases := []struct {
name string
ts1 []ep.Type
ts2 []ep.Type
expected bool
}{
{
name: "same types, same order",
ts1: []ep.Type{str, integer},
ts2: []ep.Type{str, integer},
expected: true,
}, {
name: "same types, different order",
ts1: []ep.Type{str, integer},
ts2: []ep.Type{integer, str},
expected: false,
}, {
name: "different length",
ts1: []ep.Type{integer},
ts2: []ep.Type{integer, str},
expected: false,
}, {
name: "any on one of them",
ts1: []ep.Type{integer, ep.Any},
ts2: []ep.Type{integer, str},
expected: true,
}, {
name: "any on both",
ts1: []ep.Type{integer, ep.Any, ep.Any},
ts2: []ep.Type{ep.Any, integer, ep.Any},
expected: true,
}, {
name: "only any",
ts1: []ep.Type{ep.Any, ep.Any},
ts2: []ep.Type{ep.Any, str},
expected: true,
}, {
name: "only any, different length",
ts1: []ep.Type{ep.Any},
ts2: []ep.Type{ep.Any, ep.Any},
expected: false,
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
res := ep.AreEqualTypes(tc.ts1, tc.ts2)
require.Equal(t, tc.expected, res)
// verify order doesn't affect result
res = ep.AreEqualTypes(tc.ts2, tc.ts1)
require.Equal(t, tc.expected, res)
})
}
}