X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Ftst_icu_I18N.c;h=848da691b785f84d16eba00cc548bd4860ba27a2;hb=c5a81c4eb35bcab571d42f4e02a69e4ed76dc20b;hp=bbdc9937e386150f9876dbe0227365d1a67fa299;hpb=4226453c62566c807ef457f2262acb2a1b92fe71;p=yaz-moved-to-github.git diff --git a/test/tst_icu_I18N.c b/test/tst_icu_I18N.c index bbdc993..848da69 100644 --- a/test/tst_icu_I18N.c +++ b/test/tst_icu_I18N.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2009 Index Data + * Copyright (C) 1995-2010 Index Data * See the file LICENSE for details. */ @@ -616,6 +616,97 @@ void test_chain_empty_chain(void) icu_chain_destroy(chain); } +void test_icu_iter1(void) +{ + UErrorCode status = U_ZERO_ERROR; + struct icu_chain * chain = 0; + xmlNode *xml_node; + struct icu_iter *iter; + struct icu_buf_utf8 *token; + + const char * xml_str = "" + "" + "" + ""; + + xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str)); + YAZ_CHECK(doc); + if (!doc) + return; + xml_node = xmlDocGetRootElement(doc); + YAZ_CHECK(xml_node); + if (!xml_node) + return ; + + chain = icu_chain_xml_config(xml_node, 0, &status); + + xmlFreeDoc(doc); + YAZ_CHECK(chain); + + iter = icu_iter_create(chain, "a string with 15 tokens and 8 displays"); + YAZ_CHECK(iter); + if (!iter) + return; +#if 1 + token = icu_buf_utf8_create(0); + while (icu_iter_next(iter, token)) + { + printf("[%.*s]", (int) token->utf8_len, token->utf8); + } + icu_buf_utf8_destroy(token); +#endif + + icu_iter_destroy(iter); + icu_chain_destroy(chain); +} + + +void test_icu_iter2(void) +{ + UErrorCode status = U_ZERO_ERROR; + struct icu_chain * chain = 0; + xmlNode *xml_node; + struct icu_iter *iter; + struct icu_buf_utf8 *token; + + const char * xml_str = "" + "" + "" + "" + "" + "" + "" + ""; + + xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str)); + YAZ_CHECK(doc); + if (!doc) + return; + xml_node = xmlDocGetRootElement(doc); + YAZ_CHECK(xml_node); + if (!xml_node) + return ; + + chain = icu_chain_xml_config(xml_node, 0, &status); + + xmlFreeDoc(doc); + YAZ_CHECK(chain); + + iter = icu_iter_create(chain, "Adobe Acrobat Reader, 1991-1999."); + YAZ_CHECK(iter); + if (!iter) + return; + token = icu_buf_utf8_create(0); + while (icu_iter_next(iter, token)) + { + printf("[%.*s]", (int) token->utf8_len, token->utf8); + } + icu_buf_utf8_destroy(token); + + icu_iter_destroy(iter); + icu_chain_destroy(chain); +} + #endif /* YAZ_HAVE_ICU */ int main(int argc, char **argv) @@ -632,6 +723,9 @@ int main(int argc, char **argv) test_icu_I18N_chain(argc, argv); test_chain_empty_token(); test_chain_empty_chain(); + test_icu_iter1(); + test_icu_iter2(); + test_bug_1140(); #else /* YAZ_HAVE_ICU */