forked from paulmach/go.geo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefine_test.go
49 lines (38 loc) · 984 Bytes
/
define_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
package geo
import (
"math"
"testing"
)
func TestDefineYesHaversine(t *testing.T) {
if yesHaversine(make([]bool, 0)) {
t.Error("define, yesHaversine should be false, got true")
}
if !yesHaversine([]bool{true}) {
t.Error("define, yesHaversine should be true, got false")
}
if yesHaversine([]bool{false}) {
t.Error("define, yesHaversine should be false, got true")
}
}
func TestDefineDeg2Rad(t *testing.T) {
if math.Abs(deg2rad(0.0)) > epsilon {
t.Error("define, deg2rad error")
}
if math.Abs(deg2rad(180.0)-math.Pi) > epsilon {
t.Error("define, deg2rad error")
}
if math.Abs(deg2rad(360.0)-2*math.Pi) > epsilon {
t.Error("define, deg2rad error")
}
}
func TestDefineRad2Deg(t *testing.T) {
if math.Abs(rad2deg(0.0)-0.0) > epsilon {
t.Error("define, rad2deg error")
}
if math.Abs(rad2deg(math.Pi)-180.0) > epsilon {
t.Error("define, rad2deg error")
}
if math.Abs(rad2deg(2*math.Pi)-360.0) > epsilon {
t.Error("define, rad2deg error")
}
}