296
310
test_matches(void)
298
312
RNode *root = r_new_node("", NULL);
300
314
insert_node(root, "aaa @NUMBER:number@");
301
insert_node(root, "bbb @IPv4:ipv4@");
315
insert_node(root, "bbb @IPvANY:ip@");
316
insert_node(root, "bbb4 @IPv4:ipv4@");
317
insert_node(root, "bbb6 @IPv6:ipv6@");
302
318
insert_node(root, "ccc @QSTRING:qstring:'@");
303
319
insert_node(root, "ddd @ESTRING:estring::@");
320
insert_node(root, "dddd @ESTRING:estring::*@");
321
insert_node(root, "dddd2 @ESTRING:estring::*@ d");
304
322
insert_node(root, "eee @STRING:string@");
306
test_search_matches(root, "aaa 12345 hihihi",
310
test_search_matches(root, "bbb 192.168.1.1 huhuhu",
311
"ipv4", "192.168.1.1",
314
test_search_matches(root, "ccc 'quoted string' hehehe",
315
"qstring", "quoted string",
318
test_search_matches(root, "ddd estring: hehehe",
319
"estring", "estring",
322
test_search_matches(root, "eee string hehehe",
323
insert_node(root, "fff @FLOAT:float@");
325
test_search_matches(root, "aaa 12345 hihihi",
329
test_search_matches(root, "bbb 192.168.1.1 huhuhu",
333
test_search_matches(root, "aaa 12345 hihihi",
337
test_search_matches(root, "aaa 0xaf12345 hihihi",
338
"number", "0xaf12345",
341
test_search_matches(root, "aaa 0xAF12345 hihihi",
342
"number", "0xAF12345",
345
test_search_matches(root, "aaa 0x12345 hihihi",
349
test_search_matches(root, "aaa 0XABCDEF12345ABCDEF hihihi",
350
"number", "0XABCDEF12345ABCDEF",
353
test_search_matches(root, "bbb 192.168.1.1 huhuhu",
357
test_search_matches(root, "bbb 192.168.1.1. huhuhu",
361
test_search_matches(root, "bbb4 192.168.1.1 huhuhu",
362
"ipv4", "192.168.1.1",
365
test_search_matches(root, "bbb4 192.168.1.1. huhuhu",
366
"ipv4", "192.168.1.1",
369
test_search_matches(root, "bbb 192.168.1.1huhuhu",
373
test_search_matches(root, "bbb4 192.168.1.1huhuhu",
374
"ipv4", "192.168.1.1",
377
test_search_matches(root, "bbb4 192.168.1huhuhu", NULL);
378
test_search_matches(root, "bbb4 192.168.1.huhuhu", NULL);
379
test_search_matches(root, "bbb4 192.168.1 huhuhu", NULL);
380
test_search_matches(root, "bbb4 192.168.1. huhuhu", NULL);
381
test_search_matches(root, "bbb 192.168.1huhuhu", NULL);
382
test_search_matches(root, "bbb 192.168.1.huhuhu", NULL);
383
test_search_matches(root, "bbb 192.168.1 huhuhu", NULL);
384
test_search_matches(root, "bbb 192.168.1. huhuhu", NULL);
386
test_search_matches(root, "bbb6 ABCD:EF01:2345:6789:ABCD:EF01:2345:6789 huhuhu",
387
"ipv6", "ABCD:EF01:2345:6789:ABCD:EF01:2345:6789", NULL);
389
test_search_matches(root, "bbb6 abcd:ef01:2345:6789:abcd:ef01:2345:6789 huhuhu",
390
"ipv6", "abcd:ef01:2345:6789:abcd:ef01:2345:6789", NULL);
392
test_search_matches(root, "bbb6 0:0:0:0:0:0:0:0 huhuhu",
393
"ipv6", "0:0:0:0:0:0:0:0", NULL);
395
test_search_matches(root, "bbb6 2001:DB8::8:800:200C:417A huhuhu",
396
"ipv6", "2001:DB8::8:800:200C:417A", NULL);
398
test_search_matches(root, "bbb6 FF01::101 huhuhu",
399
"ipv6", "FF01::101", NULL);
401
test_search_matches(root, "bbb6 ::1 huhuhu",
402
"ipv6", "::1", NULL);
404
test_search_matches(root, "bbb6 :: huhuhu",
407
test_search_matches(root, "bbb6 0:0:0:0:0:0:13.1.68.3 huhuhu",
408
"ipv6", "0:0:0:0:0:0:13.1.68.3", NULL);
410
test_search_matches(root, "bbb6 ::202.1.68.3 huhuhu",
411
"ipv6", "::202.1.68.3", NULL);
413
test_search_matches(root, "bbb6 2001:0DB8:0:CD30:: huhuhu",
414
"ipv6", "2001:0DB8:0:CD30::", NULL);
416
test_search_matches(root, "bbb ABCD:EF01:2345:6789:ABCD:EF01:2345:6789 huhuhu",
417
"ip", "ABCD:EF01:2345:6789:ABCD:EF01:2345:6789", NULL);
419
test_search_matches(root, "bbb abcd:ef01:2345:6789:abcd:ef01:2345:6789 huhuhu",
420
"ip", "abcd:ef01:2345:6789:abcd:ef01:2345:6789", NULL);
422
test_search_matches(root, "bbb :: huhuhu",
425
test_search_matches(root, "bbb 0:0:0:0:0:0:13.1.68.3 huhuhu",
426
"ip", "0:0:0:0:0:0:13.1.68.3", NULL);
428
test_search_matches(root, "bbb ::202.1.68.3 huhuhu",
429
"ip", "::202.1.68.3", NULL);
431
test_search_matches(root, "bbb 2001:0DB8:0:CD30:: huhuhu",
432
"ip", "2001:0DB8:0:CD30::", NULL);
434
test_search_matches(root, "bbb6 ABCD:EF01:2345:6789:ABCD:EF01:2345:6789.huhuhu",
435
"ipv6", "ABCD:EF01:2345:6789:ABCD:EF01:2345:6789", NULL);
437
test_search_matches(root, "bbb6 abcd:ef01:2345:6789:abcd:ef01:2345:6789.huhuhu",
438
"ipv6", "abcd:ef01:2345:6789:abcd:ef01:2345:6789", NULL);
440
test_search_matches(root, "bbb6 0:0:0:0:0:0:0:0.huhuhu",
441
"ipv6", "0:0:0:0:0:0:0:0", NULL);
443
test_search_matches(root, "bbb6 2001:DB8::8:800:200C:417A.huhuhu",
444
"ipv6", "2001:DB8::8:800:200C:417A", NULL);
446
test_search_matches(root, "bbb6 FF01::101.huhuhu",
447
"ipv6", "FF01::101", NULL);
449
test_search_matches(root, "bbb6 ::1.huhuhu",
450
"ipv6", "::1", NULL);
452
test_search_matches(root, "bbb6 ::.huhuhu",
455
test_search_matches(root, "bbb6 0:0:0:0:0:0:13.1.68.3.huhuhu",
456
"ipv6", "0:0:0:0:0:0:13.1.68.3", NULL);
458
test_search_matches(root, "bbb6 ::202.1.68.3.huhuhu",
459
"ipv6", "::202.1.68.3", NULL);
461
test_search_matches(root, "bbb6 2001:0DB8:0:CD30::.huhuhu",
462
"ipv6", "2001:0DB8:0:CD30::", NULL);
464
test_search_matches(root, "bbb ABCD:EF01:2345:6789:ABCD:EF01:2345:6789.huhuhu",
465
"ip", "ABCD:EF01:2345:6789:ABCD:EF01:2345:6789", NULL);
467
test_search_matches(root, "bbb abcd:ef01:2345:6789:abcd:ef01:2345:6789.huhuhu",
468
"ip", "abcd:ef01:2345:6789:abcd:ef01:2345:6789", NULL);
470
test_search_matches(root, "bbb ::.huhuhu",
473
test_search_matches(root, "bbb 0:0:0:0:0:0:13.1.68.3.huhuhu",
474
"ip", "0:0:0:0:0:0:13.1.68.3", NULL);
476
test_search_matches(root, "bbb ::202.1.68.3.huhuhu",
477
"ip", "::202.1.68.3", NULL);
479
test_search_matches(root, "bbb 2001:0DB8:0:CD30::.huhuhu",
480
"ip", "2001:0DB8:0:CD30::", NULL);
482
test_search_matches(root, "bbb 1:2:3:4:5:6:7:8.huhuhu",
483
"ip", "1:2:3:4:5:6:7:8", NULL);
485
test_search_matches(root, "bbb 1:2:3:4:5:6:7:8 huhuhu",
486
"ip", "1:2:3:4:5:6:7:8", NULL);
488
test_search_matches(root, "bbb 1:2:3:4:5:6:7:8:huhuhu",
489
"ip", "1:2:3:4:5:6:7:8", NULL);
491
test_search_matches(root, "bbb 1:2:3:4:5:6:7 huhu", NULL);
492
test_search_matches(root, "bbb 1:2:3:4:5:6:7.huhu", NULL);
493
test_search_matches(root, "bbb 1:2:3:4:5:6:7:huhu", NULL);
494
test_search_matches(root, "bbb6 1:2:3:4:5:6:7 huhu", NULL);
495
test_search_matches(root, "bbb6 1:2:3:4:5:6:7.huhu", NULL);
496
test_search_matches(root, "bbb6 1:2:3:4:5:6:7:huhu", NULL);
497
test_search_matches(root, "bbb 1:2:3:4:5:6:77777:8 huhu", NULL);
498
test_search_matches(root, "bbb 1:2:3:4:5:6:1.2.333.4 huhu", NULL);
500
test_search_matches(root, "ccc 'quoted string' hehehe",
501
"qstring", "quoted string",
504
test_search_matches(root, "ddd estring: hehehe",
505
"estring", "estring",
508
test_search_matches(root, "dddd estring:* hehehe",
509
"estring", "estring",
512
test_search_matches(root, "dddd estring:estring:* hehehe",
513
"estring", "estring:estring",
516
test_search_matches(root, "dddd estring:estring::* hehehe",
517
"estring", "estring:estring:",
520
test_search_matches(root, "dddd2 estring:estring::* d",
521
"estring", "estring:estring:",
524
test_search_matches(root, "dddd2 estring:estring::* ", NULL);
525
test_search_matches(root, "dddd2 estring:estring::*", NULL);
526
test_search_matches(root, "dddd2 estring:estring:*", NULL);
527
test_search_matches(root, "dddd2 estring:estring", NULL);
529
test_search_matches(root, "eee string hehehe",
533
test_search_matches(root, "fff 12345 hihihi",
534
"float", "12345", NULL);
536
test_search_matches(root, "fff 12345hihihi",
537
"float", "12345", NULL);
539
test_search_matches(root, "fff 12.345hihihi",
540
"float", "12.345", NULL);
542
test_search_matches(root, "fff 12.345.hihihi",
543
"float", "12.345", NULL);
545
test_search_matches(root, "fff 12.345.6hihihi",
546
"float", "12.345", NULL);
548
test_search_matches(root, "fff 12345.hihihi",
549
"float", "12345.", NULL);
551
test_search_matches(root, "aaa v12345", NULL);
552
test_search_matches(root, "bbb v12345", NULL);
553
test_search_matches(root, "bbb4 v12345", NULL);
554
test_search_matches(root, "bbb6 v12345", NULL);
555
test_search_matches(root, "ccc v12345", NULL);
556
test_search_matches(root, "ddd v12345", NULL);
557
test_search_matches(root, "dddd v12345", NULL);
558
test_search_matches(root, "fff v12345", NULL);
326
560
r_free_node(root, NULL);