-
Notifications
You must be signed in to change notification settings - Fork 2
/
tag_test.go
65 lines (51 loc) · 1.34 KB
/
tag_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
65
package cirno_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/zergon321/cirno"
)
func TestShouldCollide(t *testing.T) {
c1, err := cirno.NewCircle(cirno.NewVector(4, 4), 3)
assert.Nil(t, err)
c1.SetIdentity(32)
c1.SetMask(32)
c2, err := cirno.NewCircle(cirno.NewVector(8, 4), 2)
assert.Nil(t, err)
c2.SetIdentity(32 | 64)
c2.SetMask(32)
res0, err := cirno.ResolveCollision(c1, c2, true)
assert.Nil(t, err)
res1, err := cirno.ResolveCollision(c2, c2, true)
assert.Nil(t, err)
assert.True(t, res0)
assert.True(t, res1)
}
func TestShouldntCollide(t *testing.T) {
c1, err := cirno.NewCircle(cirno.NewVector(4, 4), 3)
assert.Nil(t, err)
c1.SetIdentity(32)
c1.SetMask(32)
c2, err := cirno.NewCircle(cirno.NewVector(8, 4), 2)
assert.Nil(t, err)
c2.SetIdentity(64)
c2.SetMask(64)
res, err := cirno.ResolveCollision(c1, c2, true)
assert.Nil(t, err)
assert.False(t, res)
}
func TestControversy(t *testing.T) {
c1, err := cirno.NewCircle(cirno.NewVector(4, 4), 3)
assert.Nil(t, err)
c1.SetIdentity(32)
c1.SetMask(32)
c2, err := cirno.NewCircle(cirno.NewVector(8, 4), 2)
assert.Nil(t, err)
c2.SetIdentity(32)
c2.SetMask(64)
res0, err := cirno.ResolveCollision(c1, c2, true)
assert.Nil(t, err)
res1, err := cirno.ResolveCollision(c2, c1, true)
assert.Nil(t, err)
assert.True(t, res0)
assert.False(t, res1)
}