-
Notifications
You must be signed in to change notification settings - Fork 1
/
ease_test.go
40 lines (35 loc) · 708 Bytes
/
ease_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
package geo
import "testing"
func TestLerp(t *testing.T) {
cases := []struct {
a, b, t float64
want float64
}{
{1, 5, 0, 1},
{1, 5, 1, 5},
{1, 5, 0.5, 3},
}
for i, c := range cases {
got := Lerp(c.a, c.b, c.t)
if got != c.want {
t.Errorf("case %d: got %f, want %f", i, got, c.want)
}
}
}
func TestLerpVec(t *testing.T) {
cases := []struct {
a, b Vec
t float64
want Vec
}{
{VecXY(1, 5), VecXY(5, 15), 0, VecXY(1, 5)},
{VecXY(1, 5), VecXY(5, 15), 1, VecXY(5, 15)},
{VecXY(1, 5), VecXY(5, 15), 0.5, VecXY(3, 10)},
}
for i, c := range cases {
got := LerpVec(c.a, c.b, c.t)
if got != c.want {
t.Errorf("case %d: got %s, want %s", i, got, c.want)
}
}
}