-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch_parse_test.go
60 lines (43 loc) · 1.08 KB
/
switch_parse_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
package finger_test
import (
"github.com/reiver/go-finger"
"testing"
)
func TestParseSwitch(t *testing.T) {
tests := []struct{
SwitchString string
Expected finger.Switch
}{
{
SwitchString: "/W",
Expected: finger.CreateSwitch("/W"),
},
{
SwitchString: "/PULL",
Expected: finger.CreateSwitch("/PULL"),
},
{
SwitchString: "/once/twice/thrice/fource",
Expected: finger.CreateSwitch("/once/twice/thrice/fource"),
},
{
SwitchString: "/",
Expected: finger.CreateSwitch("/"),
},
}
for testNumber, test := range tests {
var expected finger.Switch = test.Expected
actual, err := finger.ParseSwitch(test.SwitchString)
if nil != err {
t.Errorf("For test #%d, did not expect an error but actually got one.", testNumber)
t.Logf("ERROR: (%T) %s", err, err)
continue
}
if expected != actual {
t.Errorf("For test #%d, the actual value is not what was expected." , testNumber)
t.Logf("EXPECTED: %#v", expected)
t.Logf("ACTUAL: %#v", actual)
continue
}
}
}