-
Notifications
You must be signed in to change notification settings - Fork 2
/
contact_test.go
44 lines (35 loc) · 1.07 KB
/
contact_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
package cirno_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/zergon321/cirno"
)
func TestContactLineToCircle(t *testing.T) {
circle, err := cirno.NewCircle(cirno.NewVector(4, 6), 2)
assert.Nil(t, err)
line, err := cirno.NewLine(cirno.NewVector(2, 2), cirno.NewVector(2, 10))
assert.Nil(t, err)
contacts, err := cirno.Contact(circle, line)
assert.Nil(t, err)
assert.Equal(t, len(contacts), 1)
}
func TestContactCircleToCircle(t *testing.T) {
circle1, err := cirno.NewCircle(cirno.NewVector(4, 6), 2)
assert.Nil(t, err)
circle2, err := cirno.NewCircle(cirno.NewVector(9, 6), 3)
assert.Nil(t, err)
contacts, err := cirno.Contact(circle1, circle2)
assert.Nil(t, err)
assert.Equal(t, len(contacts), 1)
}
func TestContactLineToLine(t *testing.T) {
line1, err := cirno.NewLine(
cirno.NewVector(0, 0), cirno.NewVector(5, 5))
assert.Nil(t, err)
line2, err := cirno.NewLine(
cirno.NewVector(5, 0), cirno.NewVector(0, 5))
assert.Nil(t, err)
contacts, err := cirno.Contact(line1, line2)
assert.Nil(t, err)
assert.Equal(t, len(contacts), 1)
}