1 /* $Id: tst_index_types.c,v 1.1 2007-10-25 09:22:36 adam Exp $
2 Copyright (C) 1995-2007
5 This file is part of the Zebra server.
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
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
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
25 #include <index_types.h>
31 " <indextype id=\"*:w:el\" position=\"1\" alwaysmatches=\"1\" firstinfield=\"1\"\n"
33 " <!-- conversion rules for words -->\n"
35 " <indextype id=\"*:w\" position=\"1\" alwaysmatches=\"1\" firstinfield=\"1\"\n"
37 " <!-- conversion rules for words -->\n"
39 " <indextype id=\"*:p\" position=\"0\" alwaysmatches=\"0\" firstinfield=\"0\"\n"
41 " <!-- conversion rules for phrase -->\n"
43 " <indextype id=\"*:s\" sort=\"1\" \n"
45 " <!-- conversion rules for phrase -->\n"
50 int compare_lookup(zebra_index_types_t r, const char *id,
51 const char *expected_id)
53 const char *got_id = zebra_index_type_lookup_str(r, id);
54 if (!got_id && !expected_id)
55 return 1; /* none expected */
57 if (got_id && expected_id && !strcmp(got_id, expected_id))
64 xmlDocPtr doc = xmlParseMemory(xml_str, strlen(xml_str));
69 zebra_index_types_t rules = zebra_index_types_create_doc(doc);
75 YAZ_CHECK(compare_lookup(rules, "title:s", "*:s"));
76 YAZ_CHECK(compare_lookup(rules, "title:sx", 0));
77 YAZ_CHECK(compare_lookup(rules, "title:Sx", 0));
78 YAZ_CHECK(compare_lookup(rules, "any:w", "*:w"));
79 YAZ_CHECK(compare_lookup(rules, "any:w:en", 0));
80 YAZ_CHECK(compare_lookup(rules, "any:w:el", "*:w:el"));
84 for (i = 0; i < iter; i++)
86 compare_lookup(rules, "title:s", "*:s");
87 compare_lookup(rules, "title:sx", 0);
88 compare_lookup(rules, "title:Sx", 0);
92 zebra_index_types_destroy(rules);
96 int main(int argc, char **argv)
98 YAZ_CHECK_INIT(argc, argv);
109 * indent-tabs-mode: nil
111 * vim: shiftwidth=4 tabstop=8 expandtab