-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcircle_test.go
32 lines (28 loc) · 1.01 KB
/
circle_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
package collision2d_test
import (
"github.com/Tarliton/collision2d"
"github.com/stretchr/testify/assert"
"testing"
)
func TestCircleString(t *testing.T) {
circle := collision2d.NewCircle(collision2d.NewVector(10, 10), 5)
output := string(circle.String())
assert.Equal(t, "{Pos:{X:10.000000, Y:10.000000}\nRadius: 5.000000}", output, "they should be equal")
}
func TestCircleGetAABB(t *testing.T) {
circle := collision2d.NewCircle(collision2d.NewVector(10, 10), 5)
polygonCorners := []float64{
0, 0,
10, 0,
10, 10,
0, 10,
}
polygon := collision2d.NewPolygon(collision2d.NewVector(5, 5), collision2d.NewVector(0, 0), 0, polygonCorners)
assert.Equal(t, polygon, circle.GetAABB(), "they should be equal")
}
func TestCircleNewCircle(t *testing.T) {
circle := collision2d.NewCircle(collision2d.NewVector(5, 8), 20)
assert.Equal(t, float64(5), circle.Pos.X, "they should be equal")
assert.Equal(t, float64(8), circle.Pos.Y, "they should be equal")
assert.Equal(t, float64(20), circle.R, "they should be equal")
}