-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgnss_test.go
55 lines (51 loc) · 1.04 KB
/
gnss_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
// Copyright © 2021 The Things Network
// Use of this source code is governed by the MIT license that can be found in the LICENSE file.
package apppayload_test
import (
"reflect"
"testing"
apppayload "go.thethings.network/lorawan-application-payload"
)
func TestGNSSInference(t *testing.T) {
for _, tc := range []struct {
Name string
Input map[string]interface{}
Output []byte
Ok bool
}{
{
Name: "ValidPayload",
Input: map[string]interface{}{
"nav": "aabbccdd",
},
Output: []byte{0xaa, 0xbb, 0xcc, 0xdd},
Ok: true,
},
{
Name: "InvalidPayload",
Input: map[string]interface{}{
"nav": "aabbccddgg",
},
Ok: false,
},
{
Name: "NoKey",
Input: map[string]interface{}{
"gnss": "aabbccdd",
},
Ok: false,
},
} {
t.Run(tc.Name, func(t *testing.T) {
points, ok := apppayload.InferGNSS(tc.Input)
if tc.Ok != ok {
t.Fatal("Expected access points not found")
}
if tc.Ok {
if !reflect.DeepEqual(tc.Output, points) {
t.Fatal("Output mismatch")
}
}
})
}
}