1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2009 Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 int test_parse(struct DFA *dfa, const char *pattern)
26 const char *cp = pattern;
27 i = dfa_parse(dfa, &cp);
31 static void tst(int argc, char **argv)
33 struct DFA *dfa = dfa_init();
36 YAZ_CHECK_EQ(test_parse(dfa, ""), 1);
37 YAZ_CHECK_EQ(test_parse(dfa, "a"), 0);
38 YAZ_CHECK_EQ(test_parse(dfa, "ab"), 0);
39 YAZ_CHECK_EQ(test_parse(dfa, "(a)"), 0);
40 YAZ_CHECK_EQ(test_parse(dfa, "(a"), 1);
41 YAZ_CHECK_EQ(test_parse(dfa, "a)"), 3);
42 YAZ_CHECK_EQ(test_parse(dfa, "a\001)"), 0);
43 YAZ_CHECK_EQ(test_parse(dfa, "a\\x01"), 0);
46 YAZ_CHECK_EQ(test_parse(dfa, "(\x01\x02)(CEO3EQC/\\x01\\x0C\\x01\\x0C)"), 0);
51 int main(int argc, char **argv)
53 YAZ_CHECK_INIT(argc, argv);
62 * c-file-style: "Stroustrup"
63 * indent-tabs-mode: nil
65 * vim: shiftwidth=4 tabstop=8 expandtab