ef69d51d132e642a67b5f1419817649587bac61d
[yaz-moved-to-github.git] / test / tstmatchstr.c
1 /*
2  * Copyright (c) 2002-2004, Index Data
3  * See the file LICENSE for details.
4  *
5  * $Id: tstmatchstr.c,v 1.2 2004-09-29 20:15:42 adam Exp $
6  */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10
11 #include <yaz/yaz-iconv.h>
12
13 struct {
14     char *s1;
15     char *s2;
16     int res;
17 } comp_strings[] = {
18     { "x", "x", 0 },
19     { "x", "X", 0 },
20     { "a", "b", 1 },
21     { "b", "a", 1 },
22     { "aa","a", 1 },
23     { "a-", "a", 1 },
24     { "A-b", "ab", 0},
25     { "A--b", "ab", 1},
26     { "A--b", "a-b", 1},
27     { "A--b", "a--b", 0},
28     { "a123",  "a?", 0},
29     {"a123",   "a1.3", 0},
30     {"a123",   "..?", 0},
31     {"a123",   "a1.", 1},
32     {"a123",   "a...", 0},
33     {0,  0, 0} };
34
35 int main (int argc, char **argv)
36 {
37     int i;
38     for (i = 0; comp_strings[i].s1; i++)
39     {
40         int got = yaz_matchstr(comp_strings[i].s1,comp_strings[i].s2);
41         if (got > 0)
42             got = 1;
43         else if (got < 0)
44             got = -1;
45         if (got != comp_strings[i].res)
46         {
47             printf ("tststr %d got=%d res=%d\n", i,
48                     got, comp_strings[i].res);
49             exit(1);
50         }
51     }
52     exit(0);
53 }
54