-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcmp_test.go
33 lines (24 loc) · 1.09 KB
/
cmp_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
package ranges
import "testing"
func TestCmpFunc(t *testing.T) {
t.Parallel()
assertEqual(t, CmpFunc(1, 1), 0)
assertEqual(t, CmpFunc(1, 2), -1)
assertEqual(t, CmpFunc(2, 1), 1)
}
func TestCmp(t *testing.T) {
t.Parallel()
assertEqual(t, Cmp[int](Only[int](), Only[int](), CmpFunc[int]), 0)
assertEqual(t, Cmp[int](Only[int](), Only(1), CmpFunc[int]), -1)
assertEqual(t, Cmp[int](Only(1), Only[int](), CmpFunc[int]), 1)
assertEqual(t, Cmp[int](Only(1), Only(1), CmpFunc[int]), 0)
assertEqual(t, Cmp[int](Only(4), Only(3), CmpFunc[int]), 1)
assertEqual(t, Cmp[int](Only(2), Only(3), CmpFunc[int]), -1)
assertEqual(t, Cmp[int](Only(1, 2, 3), Only(1, 2, 3), CmpFunc[int]), 0)
assertEqual(t, Cmp[int](Only(1, 2), Only(1, 2, 3), CmpFunc[int]), -1)
assertEqual(t, Cmp[int](Only(1, 2, 3), Only(1, 2), CmpFunc[int]), 1)
assertEqual(t, Cmp[int](Only(1, 2, 4), Only(1, 2, 3), CmpFunc[int]), 1)
assertEqual(t, Cmp[int](Only(1, 2, 2), Only(1, 2, 3), CmpFunc[int]), -1)
assertEqual(t, Cmp[int](Only(4), Only(1, 2, 3), CmpFunc[int]), 1)
assertEqual(t, Cmp[int](Only(1, 2, 3), Only(4), CmpFunc[int]), -1)
}