@@ -131,136 +131,6 @@ func TestRangeUnmarshal(t *testing.T) {
131
131
}
132
132
}
133
133
134
- func TestRangeUnmarshalErrors (t * testing.T ) {
135
- for _ , ca := range []struct {
136
- name string
137
- hv base.HeaderValue
138
- err string
139
- }{
140
- {
141
- "empty" ,
142
- base.HeaderValue {},
143
- "value not provided" ,
144
- },
145
- {
146
- "2 values" ,
147
- base.HeaderValue {"a" , "b" },
148
- "value provided multiple times ([a b])" ,
149
- },
150
- {
151
- "invalid keys" ,
152
- base.HeaderValue {`key1="k` },
153
- "apexes not closed (key1=\" k)" ,
154
- },
155
- {
156
- "value not found" ,
157
- base.HeaderValue {`` },
158
- "value not found ()" ,
159
- },
160
- {
161
- "smpte without values" ,
162
- base.HeaderValue {`smpte=` },
163
- "invalid value ()" ,
164
- },
165
- {
166
- "smtpe end invalid" ,
167
- base.HeaderValue {`smpte=00:00:01-123` },
168
- "invalid SMPTE time (123)" ,
169
- },
170
- {
171
- "smpte invalid 1" ,
172
- base.HeaderValue {`smpte=123-` },
173
- "invalid SMPTE time (123)" ,
174
- },
175
- {
176
- "smpte invalid 2" ,
177
- base.HeaderValue {`smpte=aa:00:00-` },
178
- "strconv.ParseUint: parsing \" aa\" : invalid syntax" ,
179
- },
180
- {
181
- "smpte invalid 3" ,
182
- base.HeaderValue {`smpte=00:aa:00-` },
183
- "strconv.ParseUint: parsing \" aa\" : invalid syntax" ,
184
- },
185
- {
186
- "smpte invalid 4" ,
187
- base.HeaderValue {`smpte=00:00:aa-` },
188
- "strconv.ParseUint: parsing \" aa\" : invalid syntax" ,
189
- },
190
- {
191
- "smpte invalid 5" ,
192
- base.HeaderValue {`smpte=00:00:00:aa-` },
193
- "strconv.ParseUint: parsing \" aa\" : invalid syntax" ,
194
- },
195
- {
196
- "smpte invalid 6" ,
197
- base.HeaderValue {`smpte=00:00:00:aa.00-` },
198
- "strconv.ParseUint: parsing \" aa\" : invalid syntax" ,
199
- },
200
- {
201
- "smpte invalid 7" ,
202
- base.HeaderValue {`smpte=00:00:00:00.aa-` },
203
- "strconv.ParseUint: parsing \" aa\" : invalid syntax" ,
204
- },
205
- {
206
- "npt without values" ,
207
- base.HeaderValue {`npt=` },
208
- "invalid value ()" ,
209
- },
210
- {
211
- "npt end invalid" ,
212
- base.HeaderValue {`npt=00:00:00-aa` },
213
- "strconv.ParseFloat: parsing \" aa\" : invalid syntax" ,
214
- },
215
- {
216
- "npt invalid 1" ,
217
- base.HeaderValue {`npt=00:00:00:00-` },
218
- "invalid NPT time (00:00:00:00)" ,
219
- },
220
- {
221
- "npt invalid 2" ,
222
- base.HeaderValue {`npt=aa-` },
223
- "strconv.ParseFloat: parsing \" aa\" : invalid syntax" ,
224
- },
225
- {
226
- "npt invalid 3" ,
227
- base.HeaderValue {`npt=aa:00-` },
228
- "strconv.ParseUint: parsing \" aa\" : invalid syntax" ,
229
- },
230
- {
231
- "npt invalid 4" ,
232
- base.HeaderValue {`npt=aa:00:00-` },
233
- "strconv.ParseUint: parsing \" aa\" : invalid syntax" ,
234
- },
235
- {
236
- "clock without values" ,
237
- base.HeaderValue {`clock=` },
238
- "invalid value ()" ,
239
- },
240
- {
241
- "clock end invalid" ,
242
- base.HeaderValue {`clock=20060102T150405Z-aa` },
243
- "parsing time \" aa\" as \" 20060102T150405Z\" : cannot parse \" aa\" as \" 2006\" " ,
244
- },
245
- {
246
- "clock invalid 1" ,
247
- base.HeaderValue {`clock=aa-` },
248
- "parsing time \" aa\" as \" 20060102T150405Z\" : cannot parse \" aa\" as \" 2006\" " ,
249
- },
250
- {
251
- "time invalid" ,
252
- base.HeaderValue {`time=aa` },
253
- "parsing time \" aa\" as \" 20060102T150405Z\" : cannot parse \" aa\" as \" 2006\" " ,
254
- },
255
- } {
256
- t .Run (ca .name , func (t * testing.T ) {
257
- var h Range
258
- err := h .Unmarshal (ca .hv )
259
- require .EqualError (t , err , ca .err )
260
- })
261
- }
262
- }
263
-
264
134
func TestRangeMarshal (t * testing.T ) {
265
135
for _ , ca := range casesRange {
266
136
t .Run (ca .name , func (t * testing.T ) {
@@ -269,3 +139,32 @@ func TestRangeMarshal(t *testing.T) {
269
139
})
270
140
}
271
141
}
142
+
143
+ func FuzzRangeUnmarshal (f * testing.F ) {
144
+ for _ , ca := range casesRange {
145
+ f .Add (ca .vin [0 ])
146
+ }
147
+
148
+ f .Add ("smtpe=" )
149
+ f .Add ("npt=" )
150
+ f .Add ("clock=" )
151
+
152
+ f .Fuzz (func (t * testing.T , b string ) {
153
+ var h Range
154
+ h .Unmarshal (base.HeaderValue {b }) //nolint:errcheck
155
+ })
156
+ }
157
+
158
+ func TestRangeAdditionalErrors (t * testing.T ) {
159
+ func () {
160
+ var h Range
161
+ err := h .Unmarshal (base.HeaderValue {})
162
+ require .Error (t , err )
163
+ }()
164
+
165
+ func () {
166
+ var h Range
167
+ err := h .Unmarshal (base.HeaderValue {"a" , "b" })
168
+ require .Error (t , err )
169
+ }()
170
+ }
0 commit comments