]> mj.ucw.cz Git - libucw.git/blob - lib/regex-test.c
If `-S' or `-C' is given after some other options (i.e., the config file
[libucw.git] / lib / regex-test.c
1 /*
2  *      Sherlock Library -- Regular Expressions Test
3  *
4  *      (c) 2001 Robert Spalek <robert@ucw.cz>
5  */
6
7 #include "lib/lib.h"
8
9 #include <stdio.h>
10
11 #define PREPARE(patt, icase)    r = rx_compile(patt, icase); printf("\npattern: %s, icase=%d\n", patt, icase)
12 #define TEST(txt, should)       printf(txt ": %d (should %d)\n", rx_match(r, txt), should)
13
14 int
15 main(void)
16 {
17         regex *r;
18
19         PREPARE("a.*b.*c", 0);
20         TEST("abc", 1);
21         TEST("ajkhkbbbbbc", 1);
22         TEST("Aabc", 0);
23         rx_free(r);
24
25         PREPARE("a.*b.*c", 1);
26         TEST("aBc", 1);
27         TEST("ajkhkbBBBBC", 1);
28         TEST("Aabc", 1);
29         rx_free(r);
30
31         PREPARE("(ahoj|nebo)", 1);
32         TEST("Ahoj", 1);
33         TEST("nEBo", 1);
34         TEST("ahoja", 0);
35         TEST("(ahoj|nebo)", 0);
36         rx_free(r);
37
38         PREPARE("\\(ahoj\\)", 0);
39         TEST("(ahoj)", 1);
40         TEST("ahoj", 0);
41         rx_free(r);
42
43         return 0;
44 }