-
Notifications
You must be signed in to change notification settings - Fork 0
/
token_test.go
60 lines (53 loc) · 1.26 KB
/
token_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
package tok
import (
"testing"
)
func TestTokenCovers(t *testing.T) {
t_02_23 := MakeToken(Marker(2), Marker(23))
t_10_30 := MakeToken(Marker(10), Marker(30))
t_11_19 := MakeToken(Marker(11), Marker(19))
cases := []struct {
t Token
oth Token
exp bool
}{
{t_02_23, t_10_30, false},
{t_10_30, t_02_23, false},
{t_02_23, t_11_19, true},
{t_11_19, t_02_23, false},
{t_10_30, t_11_19, true},
{t_11_19, t_10_30, false},
}
for _, c := range cases {
res := c.t.Covers(c.oth)
if res != c.exp {
t.Errorf("unexpected Covers result between %v and %v: %v", c.t, c.oth, res)
}
}
}
func TestTokenClash(t *testing.T) {
t_03_08 := MakeToken(Marker(3), Marker(8))
t_02_23 := MakeToken(Marker(2), Marker(23))
t_10_30 := MakeToken(Marker(10), Marker(30))
t_11_19 := MakeToken(Marker(11), Marker(19))
cases := []struct {
t Token
oth Token
exp bool
}{
{t_02_23, t_10_30, true},
{t_10_30, t_02_23, true},
{t_02_23, t_11_19, false},
{t_11_19, t_02_23, false},
{t_10_30, t_11_19, false},
{t_11_19, t_10_30, false},
{t_03_08, t_10_30, false},
{t_10_30, t_03_08, false},
}
for _, c := range cases {
res := c.t.Clashes(c.oth)
if res != c.exp {
t.Errorf("unexpected Clashes result between %v and %v: %v", c.t, c.oth, res)
}
}
}