X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=test%2Ftst_icu_I18N.c;h=39b084e7f68692af51952a35058120e3e3bb5fe4;hb=9edd0f41a0323104c2632c2291eae336ab60874c;hp=6daa5e75d9ae793c2145b2f223c23e1608955d87;hpb=30212597593ba71295ef0b98aa3527526754a1eb;p=yaz-moved-to-github.git diff --git a/test/tst_icu_I18N.c b/test/tst_icu_I18N.c index 6daa5e7..39b084e 100644 --- a/test/tst_icu_I18N.c +++ b/test/tst_icu_I18N.c @@ -1,4 +1,4 @@ -/* $Id: tst_icu_I18N.c,v 1.3 2007-10-23 07:51:57 marc Exp $ +/* $Id: tst_icu_I18N.c,v 1.4 2007-10-24 07:41:48 marc Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -612,8 +612,15 @@ void test_bug_1140(void) chain, "O Romeo, Romeo! wherefore art thou\t Romeo?", &status)); - while (icu_chain_next_token(chain, &status)) + while (icu_chain_next_token(chain, &status)){ ; + printf("%d '%s' '%s'\n", + icu_chain_get_token_count(chain), + icu_chain_get_norm(chain), + icu_chain_get_display(chain)); + + } + YAZ_CHECK_EQ(icu_chain_get_token_count(chain), 7); @@ -621,10 +628,10 @@ void test_bug_1140(void) while (icu_chain_next_token(chain, &status)){ ; - //printf("%d '%s' '%s'\n", - // icu_chain_get_token_count(chain), - // icu_chain_get_norm(chain), - // icu_chain_get_display(chain)); + printf("%d '%s' '%s'\n", + icu_chain_get_token_count(chain), + icu_chain_get_norm(chain), + icu_chain_get_display(chain)); } /* we expect 'what' 'is' 'this', i.e. 3 tokens */ @@ -633,6 +640,47 @@ void test_bug_1140(void) icu_chain_destroy(chain); } + + +void test_chain_empty_token(void) +{ + UErrorCode status = U_ZERO_ERROR; + struct icu_chain * chain = 0; + + const char * xml_str = "" + "" + "" + "" + ""; + + xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str)); + xmlNode *xml_node = xmlDocGetRootElement(doc); + YAZ_CHECK(xml_node); + + chain = icu_chain_xml_config(xml_node, &status); + + xmlFreeDoc(doc); + YAZ_CHECK(chain); + + YAZ_CHECK(icu_chain_assign_cstr( + chain, " ", + &status)); + + while (icu_chain_next_token(chain, &status)){ + ; + printf("%d '%s' '%s'\n", + icu_chain_get_token_count(chain), + icu_chain_get_norm(chain), + icu_chain_get_display(chain)); + } + + // this should result in one toke, namely the empty token '', + // but it has none. + YAZ_CHECK_EQ(icu_chain_get_token_count(chain), 0); + + icu_chain_destroy(chain); +} + #endif // HAVE_ICU /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */ @@ -647,9 +695,10 @@ int main(int argc, char **argv) test_icu_I18N_casemap(argc, argv); test_icu_I18N_sortmap(argc, argv); - test_icu_I18N_normalizer(argc, argv); + test_icu_I18N_normalizer(argc, argv); test_icu_I18N_tokenizer(argc, argv); test_icu_I18N_chain(argc, argv); + //test_chain_empty_token(); test_bug_1140(); #else /* HAVE_ICU */