forked from mmp/vice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaviation_test.go
41 lines (35 loc) · 1.07 KB
/
aviation_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
// aviation_test.go
// Copyright(c) 2022 Matt Pharr, licensed under the GNU Public License, Version 3.
// SPDX: GPL-3.0-only
package main
import (
"testing"
)
func TestFrequencyFormat(t *testing.T) {
type FS struct {
f Frequency
s string
}
for _, fs := range []FS{FS{f: Frequency(121900), s: "121.900"},
FS{f: Frequency(130050), s: "130.050"},
FS{f: Frequency(128000), s: "128.000"},
} {
if fs.f.String() != fs.s {
t.Errorf("Frequency String() %q; expected %q", fs.f.String(), fs.s)
}
}
}
func TestParseSquawk(t *testing.T) {
for _, squawk := range []string{"11111", "7778", "0801", "9000"} {
if _, err := ParseSquawk(squawk); err == nil {
t.Errorf("Expected error return value for invalid squawk %q", squawk)
}
}
for _, squawk := range []string{"0601", "3700", "7777", "0000", "1724"} {
if ps, err := ParseSquawk(squawk); err != nil {
t.Errorf("%v: Unexpected error return value for valid squawk %q", err, squawk)
} else if ps.String() != squawk {
t.Errorf("Parsing squawk %s doesn't give match from String(): %s", squawk, ps.String())
}
}
}