X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Ftest_icu.c;h=5107693d0bf933a91f6b436944382f7189726047;hb=eb556013557ef8c9e76c52614f88c059ec443c95;hp=cf9e4e84bc28829256cf183572c7a808bcec1276;hpb=7e4656f4fb50445df3713d6bea33a6fc4c5ab3d8;p=yaz-moved-to-github.git diff --git a/test/test_icu.c b/test/test_icu.c index cf9e4e8..5107693 100644 --- a/test/test_icu.c +++ b/test/test_icu.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2013 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ @@ -897,6 +897,68 @@ static void check_icu_iter4(void) } +static void check_norm(void) +{ + UErrorCode status = U_ZERO_ERROR; + struct icu_chain *chain = 0; + xmlNode *xml_node; + yaz_icu_iter_t it; + + 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, 1, &status); + + it = icu_iter_create(chain); + if (it) + { + icu_iter_first(it, " y😄"); + while (icu_iter_next(it)) + { + const char *norm_str = icu_iter_get_norm(it); + size_t start, len; + + YAZ_CHECK(norm_str); + if (norm_str) + yaz_log(YLOG_LOG, "norm_str len=%ld=%s", + (long) strlen(norm_str), norm_str); + icu_iter_get_org_info(it, &start, &len); + YAZ_CHECK(start <= 1000); + YAZ_CHECK(len <= 1000); + } + + icu_iter_first(it, "\n y😄"); + while (icu_iter_next(it)) + { + const char *norm_str = icu_iter_get_norm(it); + size_t start, len; + + YAZ_CHECK(norm_str); + if (norm_str) + yaz_log(YLOG_LOG, "norm_str len=%ld=%s", + (long) strlen(norm_str), norm_str); + icu_iter_get_org_info(it, &start, &len); + YAZ_CHECK(start <= 1000); + YAZ_CHECK(len <= 1000); + } + } + icu_iter_destroy(it); + icu_chain_destroy(chain); + xmlFreeDoc(doc); +} #endif /* YAZ_HAVE_ICU */ int main(int argc, char **argv) @@ -919,6 +981,7 @@ int main(int argc, char **argv) check_icu_iter4(); check_bug_1140(); + check_norm(); u_cleanup(); #if YAZ_HAVE_XML2