X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=util%2Ftst_index_types.c;h=2e0c0ac5c038cf9aaba640590de9c7d75ca91041;hb=1c2f77dd881bcf0b2718cafeb380581634a165fb;hp=95d33306b929116bd06489906b80fa83581e31d1;hpb=f4767dc0b946394baeeaed3fea5b8579d170ab5e;p=idzebra-moved-to-github.git diff --git a/util/tst_index_types.c b/util/tst_index_types.c index 95d3330..2e0c0ac 100644 --- a/util/tst_index_types.c +++ b/util/tst_index_types.c @@ -1,4 +1,4 @@ -/* $Id: tst_index_types.c,v 1.1 2007-10-25 09:22:36 adam Exp $ +/* $Id: tst_index_types.c,v 1.3 2007-10-25 19:25:00 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include @@ -30,19 +29,19 @@ const char *xml_str = " " " \n" -" \n" +" \n" " \n" " \n" -" \n" +" \n" " \n" " \n" -" \n" +" \n" " \n" " \n" -" \n" +" \n" " \n" " \n" ; @@ -61,12 +60,14 @@ int compare_lookup(zebra_index_types_t r, const char *id, void tst1(void) { +#if YAZ_HAVE_XML2 xmlDocPtr doc = xmlParseMemory(xml_str, strlen(xml_str)); YAZ_CHECK(doc); if (doc) { zebra_index_types_t rules = zebra_index_types_create_doc(doc); + zebra_index_type_t type; YAZ_CHECK(rules); if (!rules) @@ -89,8 +90,62 @@ void tst1(void) } } + type = zebra_index_type_get(rules, "any:w"); + YAZ_CHECK(type); + if (type) + { + const char *buf = " How are you?"; + size_t len = strlen(buf); + int r = 1; + + if (r) + { + const char *result_buf = 0; + size_t result_len = 0; + r = zebra_index_type_tokenize(type, buf, len, + &result_buf, &result_len); + YAZ_CHECK_EQ(r, 1); + YAZ_CHECK(result_len == 3 && + !memcmp(result_buf, "how", result_len)); + } + + if (r) + { + const char *result_buf = 0; + size_t result_len = 0; + r = zebra_index_type_tokenize(type, 0, 0, + &result_buf, &result_len); + YAZ_CHECK_EQ(r, 1); + YAZ_CHECK(result_len == 3 && + !memcmp(result_buf, "are", result_len)); + } + + if (r) + { + const char *result_buf = 0; + size_t result_len = 0; + r = zebra_index_type_tokenize(type, 0, 0, + &result_buf, &result_len); + YAZ_CHECK_EQ(r, 1); + YAZ_CHECK(result_len == 3 && + !memcmp(result_buf, "you", result_len)); + } + + if (r) + { + const char *result_buf = 0; + size_t result_len = 0; + r = zebra_index_type_tokenize(type, 0, 0, + &result_buf, &result_len); + YAZ_CHECK_EQ(r, 0); + } + } zebra_index_types_destroy(rules); } +#else + zebra_index_types_t rules = zebra_index_types_create_doc(doc); + YAZ_CHECK(!rules); +#endif } int main(int argc, char **argv)