-
Notifications
You must be signed in to change notification settings - Fork 0
/
metarg_test.go
47 lines (43 loc) · 979 Bytes
/
metarg_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
package main
import (
"testing"
)
func TestParseArgsBasic(t *testing.T) {
const metarCode = "KPKW"
args := []string{"-d", metarCode}
flagSet, success := ParseArgs(args)
t.Logf("Got %v, %v", flagSet, success)
if !success {
t.Error("Failed to parse but should've succeeded")
}
if !flagSet.Parsed() {
t.Error("Should be parsed")
}
if len(flagSet.Args()) != 1 {
t.Error("Wrong args length")
}
if flagSet.Args()[0] != metarCode {
t.Error("Wrong METAR code")
}
if !decode {
t.Error("Decode should be true")
}
if help {
t.Error("Help should be false")
}
}
//TODO make these run without writing to stdout... annoying
//func TestParseArgsInvalid(t *testing.T) {
// args := []string{"-wrong", "KPKW"}
// _, success := ParseArgs(args)
// if success {
// t.Error("Should've failed")
// }
//}
//func TestParseArgsMissingMetar(t *testing.T) {
// args := []string{"-d"}
// _, success := ParseArgs(args)
// if success {
// t.Error("Should've failed")
// }
//}