-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuncs_sequence_test.go
52 lines (46 loc) · 1.53 KB
/
funcs_sequence_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
package handy
import (
"github.com/hsldymq/goiter"
"testing"
)
func TestSequenceEqual(t *testing.T) {
// case 1
e1 := NewEnumerator(goiter.SliceElems([]int{1, 2, 3, 4, 5}))
e2 := NewEnumerator(goiter.SliceElems([]int{1, 2, 3, 4, 5}))
if !sequenceEqual[int](e1, e2) {
t.Fatalf("test sequenceEqual failed, expect true")
}
// case 2
e1 = NewEnumerator(goiter.SliceElems([]int{1, 2, 3, 4, 5, 6}))
e2 = NewEnumerator(goiter.SliceElems([]int{1, 2, 3, 4, 5}))
if sequenceEqual[int](e1, e2) {
t.Fatalf("test sequenceEqual failed, expect false")
}
// case 3
e1 = NewEnumerator(goiter.SliceElems([]int{1, 2, 0, 4, 5}))
e2 = NewEnumerator(goiter.SliceElems([]int{1, 2, 3, 4, 5}))
if sequenceEqual[int](e1, e2) {
t.Fatalf("test sequenceEqual failed, expect false")
}
// case 4
ep1 := NewEnumerator(goiter.SliceElems([]*personWithID{
{ID: "1", Name: "Alice"},
{ID: "2", Name: "Bob"},
{ID: "3", Name: "Eve"},
}))
ep2 := NewEnumerator(goiter.SliceElems([]*personWithID{
{ID: "1", Name: "Eve"},
{ID: "2", Name: "Alice"},
{ID: "3", Name: "Bob"},
}))
if !sequenceEqual[*personWithID](ep1, ep2) {
t.Fatalf("test sequenceEqual failed, expect true")
}
// case 5
f := func() {}
ef1 := NewEnumerator(goiter.SliceElems([]func(){f}))
ef2 := NewEnumerator(goiter.SliceElems([]func(){f}))
if sequenceEqual[func()](ef1, ef2) {
t.Fatalf("test sequenceEqual failed, expect false")
}
}