dab3efc6f213a1ac49a6269349c2ca153c0913eb
[yaz-moved-to-github.git] / test / tst_match_glob.c
1 /* $Id: tst_match_glob.c,v 1.1 2007-10-24 13:50:03 adam Exp $
2    Copyright (C) 1995-2007
3    Index Data ApS
4
5 This file is part of the Zebra server.
6
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
21 */
22
23 #include <yaz/test.h>
24 #include <yaz/match_glob.h>
25 #include <stdlib.h>
26 #include <string.h>
27
28 void tst1(void)
29 {
30     YAZ_CHECK_EQ(yaz_match_glob("a", "a"), 1);
31     YAZ_CHECK_EQ(yaz_match_glob("", ""), 1);
32     YAZ_CHECK_EQ(yaz_match_glob("a", ""), 0);
33     YAZ_CHECK_EQ(yaz_match_glob("", "a"), 0);
34     YAZ_CHECK_EQ(yaz_match_glob("a", "b"), 0);
35     YAZ_CHECK_EQ(yaz_match_glob("b", "a"), 0);
36
37     YAZ_CHECK_EQ(yaz_match_glob("?", "a"), 1);
38     YAZ_CHECK_EQ(yaz_match_glob("a", "?"), 0);
39     YAZ_CHECK_EQ(yaz_match_glob("?", "aa"), 0);
40     YAZ_CHECK_EQ(yaz_match_glob("?a", "aa"), 1);
41     YAZ_CHECK_EQ(yaz_match_glob("a?", "aa"), 1);
42     YAZ_CHECK_EQ(yaz_match_glob("??", "aa"), 1);
43
44     YAZ_CHECK_EQ(yaz_match_glob("*", ""), 1);
45     YAZ_CHECK_EQ(yaz_match_glob("*", "a"), 1);
46     YAZ_CHECK_EQ(yaz_match_glob("**", "a"), 1);
47     YAZ_CHECK_EQ(yaz_match_glob("*a", "a"), 1);
48     YAZ_CHECK_EQ(yaz_match_glob("a*", "a"), 1);
49     YAZ_CHECK_EQ(yaz_match_glob("b*", "a"), 0);
50     YAZ_CHECK_EQ(yaz_match_glob("*b", "a"), 0);
51     YAZ_CHECK_EQ(yaz_match_glob("**b", "a"), 0);
52     YAZ_CHECK_EQ(yaz_match_glob("*b*", "a"), 0);
53
54     YAZ_CHECK_EQ(yaz_match_glob("*:w", "title:w"), 1);
55     YAZ_CHECK_EQ(yaz_match_glob("title:w", "title:w"), 1);
56     YAZ_CHECK_EQ(yaz_match_glob("title:*", "title:w"), 1);
57 }
58
59 int main(int argc, char **argv)
60 {
61     YAZ_CHECK_INIT(argc, argv);
62
63     tst1();
64
65     YAZ_CHECK_TERM;
66 }
67
68 /*
69  * Local variables:
70  * c-basic-offset: 4
71  * indent-tabs-mode: nil
72  * End:
73  * vim: shiftwidth=4 tabstop=8 expandtab
74  */
75