File tree 1 file changed +76
-0
lines changed
1 file changed +76
-0
lines changed Original file line number Diff line number Diff line change @@ -279,6 +279,82 @@ static void test_quantifiers() {
279
279
" catyyy" ,
280
280
}
281
281
);
282
+ test_grammar (
283
+ " simple exact repetition" ,
284
+ // Grammar
285
+ R"""(
286
+ root ::= [ab]{4}
287
+ )""" ,
288
+ // Passing strings
289
+ {
290
+ " aaaa" ,
291
+ " bbbb" ,
292
+ " abab" ,
293
+ },
294
+ // Failing strings
295
+ {
296
+ " a" ,
297
+ " b" ,
298
+ " aaaaa" ,
299
+ }
300
+ );
301
+ test_grammar (
302
+ " simple min repetition" ,
303
+ // Grammar
304
+ R"""(
305
+ root ::= [ab]{4,}
306
+ )""" ,
307
+ // Passing strings
308
+ {
309
+ " aaaa" ,
310
+ " aaaaab" ,
311
+ " bbbb" ,
312
+ " ababab" ,
313
+ },
314
+ // Failing strings
315
+ {
316
+ " " ,
317
+ " aba" ,
318
+ }
319
+ );
320
+ test_grammar (
321
+ " simple max repetition" ,
322
+ // Grammar
323
+ R"""(
324
+ root ::= [ab]{0,4}
325
+ )""" ,
326
+ // Passing strings
327
+ {
328
+ " " ,
329
+ " a" ,
330
+ " aa" ,
331
+ " aaa" ,
332
+ " aaab" ,
333
+ },
334
+ // Failing strings
335
+ {
336
+ " aaaaa" ,
337
+ }
338
+ );
339
+ test_grammar (
340
+ " min / max repetition" ,
341
+ // Grammar
342
+ R"""(
343
+ root ::= ("0x" [A-F0-9]{2} " "?){3,5}
344
+ )""" ,
345
+ // Passing strings
346
+ {
347
+ " 0xFF 0x12 0xAB" ,
348
+ " 0xFF 0x12 0xAB 0x00 0x00" ,
349
+ },
350
+ // Failing strings
351
+ {
352
+ " " ,
353
+ " 0xFF" ,
354
+ " 0xFF 0x12" ,
355
+ " 0xFF 0x12 0xAB 0x00 0x00 0x00" ,
356
+ }
357
+ );
282
358
}
283
359
284
360
static void test_failure_missing_root () {
You can’t perform that action at this time.
0 commit comments