-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoords_test.go
More file actions
86 lines (71 loc) · 1.81 KB
/
coords_test.go
File metadata and controls
86 lines (71 loc) · 1.81 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
85
86
package nvector_test
import (
"context"
"testing"
. "github.com/ezzatron/nvector-go"
"github.com/ezzatron/nvector-go/internal/equality"
"github.com/ezzatron/nvector-go/internal/rapidgen"
"github.com/ezzatron/nvector-go/internal/testapi"
"pgregory.net/rapid"
)
func Test_FromGeodeticCoordinates(t *testing.T) {
client, err := testapi.NewClient()
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() {
client.Close()
})
ctx := context.Background()
t.Run("it matches the reference implementation", func(t *testing.T) {
rapid.Check(t, func(t *rapid.T) {
c := rapidgen.GeodeticCoordinates().Draw(t, "coords")
f := rapidgen.RotationMatrix().Draw(t, "coordFrame")
want, err := client.FromGeodeticCoordinates(ctx, c, f)
if err != nil {
t.Fatal(err)
}
got := FromGeodeticCoordinates(c, f)
if eq, ineq := equality.EqualToVector(got, want, 1e-14); !eq {
equality.ReportInequalities(t, ineq)
}
})
})
}
func Test_ToGeodeticCoordinates(t *testing.T) {
client, err := testapi.NewClient()
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() {
client.Close()
})
ctx := context.Background()
t.Run("it matches the reference implementation", func(t *testing.T) {
rapid.Check(t, func(t *rapid.T) {
v := rapidgen.UnitVector().Draw(t, "nVector")
f := rapidgen.RotationMatrix().Draw(t, "coordFrame")
want, err := client.ToGeodeticCoordinates(ctx, v, f)
if err != nil {
t.Fatal(err)
}
got := ToGeodeticCoordinates(v, f)
latEq, latIneq := equality.EqualToRadians(
got.Latitude,
want.Latitude,
1e-14,
)
lonEq, lonIneq := equality.EqualToRadians(
got.Longitude,
want.Longitude,
1e-14,
)
if !latEq {
equality.ReportInequality(t, "latitude", latIneq)
}
if !lonEq {
equality.ReportInequality(t, "longitude", lonIneq)
}
})
})
}