Add truncation tests
[yaz-moved-to-github.git] / test / test_matchstr.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2011 Index Data
3  * See the file LICENSE for details.
4  */
5 #if HAVE_CONFIG_H
6 #include <config.h>
7 #endif
8
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 #include <yaz/matchstr.h>
13 #include <yaz/test.h>
14
15 int main (int argc, char **argv)
16 {
17     YAZ_CHECK_INIT(argc, argv);
18
19     YAZ_CHECK(yaz_matchstr("x", "x") == 0);
20     YAZ_CHECK(yaz_matchstr("x", "X") == 0);
21     YAZ_CHECK(yaz_matchstr("a", "b") > 0);
22     YAZ_CHECK(yaz_matchstr("b", "a") > 0);
23     YAZ_CHECK(yaz_matchstr("aa","a") > 0);
24     YAZ_CHECK(yaz_matchstr("a-", "a") > 0);
25     YAZ_CHECK(yaz_matchstr("A-b", "ab") == 0);
26     YAZ_CHECK(yaz_matchstr("A--b", "ab") > 0);
27     YAZ_CHECK(yaz_matchstr("A--b", "a-b") > 0);
28     YAZ_CHECK(yaz_matchstr("A--b", "a--b") == 0);
29     YAZ_CHECK(yaz_matchstr("a123",  "a?") == 0);
30     YAZ_CHECK(yaz_matchstr("a123",   "a1.3") == 0);
31     YAZ_CHECK(yaz_matchstr("a123",   "..?") == 0);
32     YAZ_CHECK(yaz_matchstr("a123",   "a1.") > 0);
33     YAZ_CHECK(yaz_matchstr("a123",   "a...") == 0);
34
35     YAZ_CHECK_TERM;
36 }
37
38 /*
39  * Local variables:
40  * c-basic-offset: 4
41  * c-file-style: "Stroustrup"
42  * indent-tabs-mode: nil
43  * End:
44  * vim: shiftwidth=4 tabstop=8 expandtab
45  */
46