-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsfv_test.go
154 lines (130 loc) · 3.36 KB
/
sfv_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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package sfv
import "testing"
func TestExamples(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/examples.json")
}
func TestLargeGenerated(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/large-generated.json")
}
func TestList(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/list.json")
}
func TestParamList(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/param-list.json")
}
func TestListList(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/listlist.json")
}
func TestParamListList(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/param-listlist.json")
}
func TestDictionary(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/dictionary.json")
}
func TestParamDict(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/param-dict.json")
}
func TestKeyGenerated(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/key-generated.json")
}
func TestItem(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/item.json")
}
func TestNumber(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/number.json")
}
func TestNumberGenerated(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/number-generated.json")
}
func TestString(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/string.json")
}
func TestStringGenerated(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/string-generated.json")
}
func TestToken(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/token.json")
}
func TestTokenGenerated(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/token-generated.json")
}
func TestBinary(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/binary.json")
}
func TestBoolean(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/boolean.json")
}
func TestDate(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/date.json")
}
func TestDisplayString(t *testing.T) {
runTestCases(t, "./testdata/structured-field-tests/display-string.json")
}
func TestExtra(t *testing.T) {
// This test is not part of the structured-field-tests suite.
runTestCases(t, "./testdata/extra.json")
}
func TestToken_Valid(t *testing.T) {
cases := []struct {
in string
want bool
}{
{"", false},
{"*", true},
{"a", true},
{"z", true},
{"A", true},
{"Z", true},
{"0", false},
{":", false},
{"/", false},
{"!", false},
{"\"", false},
{"#", false},
{"$", false},
{"%", false},
{"&", false},
{"'", false},
{"(", false},
{")", false},
{"aa", true},
{"aA", true},
{"a0", true},
{"a:", true},
{"a/", true},
}
for _, c := range cases {
if got := Token(c.in).Valid(); got != c.want {
t.Errorf("Token(%q).Valid() = %v, want %v", c.in, got, c.want)
}
}
}
func TestIsValidString(t *testing.T) {
cases := []struct {
in string
want bool
}{
{"", true},
{"*", true},
{"a", true},
{"z", true},
{"A", true},
{"Z", true},
{"0", true},
{"9", true},
{"~", true},
{"aa", true},
{" ", true},
{"\t", false},
{"\a", false},
{"\n", false},
{"\r", false},
{"\f", false},
{"\u0080", false},
}
for _, c := range cases {
if got := IsValidString(c.in); got != c.want {
t.Errorf("isValidString(%q) = %v, want %v", c.in, got, c.want)
}
}
}