forked from EngoEngine/engo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath_test.go
More file actions
84 lines (68 loc) · 1.39 KB
/
Copy pathmath_test.go
File metadata and controls
84 lines (68 loc) · 1.39 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package engo
import "testing"
func TestPointPointAddition(t *testing.T) {
a := Point{2, 5}
b := Point{3, 1}
a.Add(b)
if a.X != 5 {
t.Errorf("a.X should equal 5 not %v", a.X)
}
if a.Y != 6 {
t.Errorf("a.Y should equal 6 not %v", a.Y)
}
}
func TestPointPointSubtraction(t *testing.T) {
a := Point{10, 15}
b := Point{5, 2}
a.Subtract(b)
if a.X != 5 {
t.Errorf("a.X should equal 5 not %v", a.X)
}
if a.Y != 13 {
t.Errorf("a.Y should equal 13 not %v", a.Y)
}
}
func TestPointPointMultiplication(t *testing.T) {
a := Point{10, 2}
b := Point{5, 6}
a.Multiply(b)
if a.X != 50 {
t.Errorf("a.X should equal 50 not %v", a.X)
}
if a.Y != 12 {
t.Errorf("a.Y should equal 12 not %v", a.Y)
}
}
func TestPointScalarAddition(t *testing.T) {
a := Point{2, 4}
s := float32(1)
a.AddScalar(s)
if a.X != 3 {
t.Errorf("a.X should equal 3 not %v", a.X)
}
if a.Y != 5 {
t.Errorf("a.Y should equal 5 not %v", a.Y)
}
}
func TestPointScalarSubtraction(t *testing.T) {
a := Point{10, 20}
s := float32(2)
a.SubtractScalar(s)
if a.X != 8 {
t.Errorf("a.X should equal 8 not %v", a.X)
}
if a.Y != 18 {
t.Errorf("a.Y should equal 18 not %v", a.Y)
}
}
func TestPointScalarMultiplication(t *testing.T) {
a := Point{5, 6}
s := float32(3)
a.MultiplyScalar(s)
if a.X != 15 {
t.Errorf("a.X should equal 15 not %v", a.X)
}
if a.Y != 18 {
t.Errorf("a.X should equal 18 not %v", a.Y)
}
}