-
Notifications
You must be signed in to change notification settings - Fork 4
/
planet_test.go
67 lines (62 loc) · 1.67 KB
/
planet_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package novas_test
import (
"github.com/pebbe/novas"
"fmt"
"testing"
"time"
)
func TestAppPlanet(t *testing.T) {
nt := novas.Date(2012, 12, 13, 12, 0, 0, 0, time.UTC)
sun := novas.Sun()
data := sun.App(nt)
tests := [][3]string{
{"Right ascension", "17.411478", fmt.Sprintf("%.6f", data.RA)},
{"Declination", "-23.187682", fmt.Sprintf("%.6f", data.Dec)},
{"Distance in AU", "0.984424", fmt.Sprintf("%.6f", data.Dis)},
{"Ecliptic longitude", "261.890295", fmt.Sprintf("%.6f", data.ELon)},
{"Ecliptic latitude", "0.001755", fmt.Sprintf("%.6f", data.ELat)},
}
for _, test := range tests {
if test[1] != test[2] {
t.Errorf("%s: expected %s, got %s", test[0], test[1], test[2])
}
}
}
func TestTopoPlanet(t *testing.T) {
nt := novas.Date(2012, 12, 13, 12, 0, 0, 0, time.UTC)
sun := novas.Sun()
place := novas.NewPlace(53.21853, 6.5670, 0, 18, 1010)
data := sun.Topo(nt, place, novas.REFR_NONE)
tests := [][3]string{
{"Distance in AU", "0.984414", fmt.Sprintf("%.6f", data.Dis)},
{"Altitude", "13.278250", fmt.Sprintf("%.6f", data.Alt)},
{"Azimuth", "187.524224", fmt.Sprintf("%.6f", data.Az)},
}
for _, test := range tests {
if test[1] != test[2] {
t.Errorf("%s: expected %s, got %s", test[0], test[1], test[2])
}
}
}
func TestDisc(t *testing.T) {
tests := []string{
"Moon 62",
"Mercury 13",
"Venus 48",
"Mars 97",
"Jupiter 100",
}
nt := novas.Date(2012, 4, 1, 0, 0, 0, 0, time.UTC)
for i, n := range []*novas.Body{
novas.Moon(),
novas.Mercury(),
novas.Venus(),
novas.Mars(),
novas.Jupiter(),
} {
got := fmt.Sprintf("%s %.0f", n.Name(), n.Disc(nt))
if tests[i] != got {
t.Errorf("expected %s, got %s", tests[i], got)
}
}
}