| OLD | NEW |
| 1 /******************************************************************** | 1 /******************************************************************** |
| 2 * Copyright (c) 1999-2010, International Business Machines | 2 * Copyright (c) 1999-2010, International Business Machines |
| 3 * Corporation and others. All Rights Reserved. | 3 * Corporation and others. All Rights Reserved. |
| 4 ******************************************************************** | 4 ******************************************************************** |
| 5 * Date Name Description | 5 * Date Name Description |
| 6 * 12/14/99 Madhu Creation. | 6 * 12/14/99 Madhu Creation. |
| 7 * 01/12/2000 Madhu updated for changed API | 7 * 01/12/2000 Madhu updated for changed API |
| 8 ********************************************************************/ | 8 ********************************************************************/ |
| 9 | 9 |
| 10 #include "unicode/utypes.h" | 10 #include "unicode/utypes.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 UErrorCode status = U_ZERO_ERROR; | 149 UErrorCode status = U_ZERO_ERROR; |
| 150 BreakIterator* a = BreakIterator::createWordInstance(Locale("hi"), status); | 150 BreakIterator* a = BreakIterator::createWordInstance(Locale("hi"), status); |
| 151 BreakIterator* b = BreakIterator::createWordInstance(Locale("hi_IN"),status)
; | 151 BreakIterator* b = BreakIterator::createWordInstance(Locale("hi_IN"),status)
; |
| 152 if (U_FAILURE(status)) { | 152 if (U_FAILURE(status)) { |
| 153 errcheckln(status, "Creation of break iterator failed %s", u_errorName(s
tatus)); | 153 errcheckln(status, "Creation of break iterator failed %s", u_errorName(s
tatus)); |
| 154 return; | 154 return; |
| 155 } | 155 } |
| 156 if(*a!=*b){ | 156 if(*a!=*b){ |
| 157 errln("Failed: boilerplate method operator!= does not return correct res
ults"); | 157 errln("Failed: boilerplate method operator!= does not return correct res
ults"); |
| 158 } | 158 } |
| 159 BreakIterator* c = BreakIterator::createWordInstance(Locale("ja"),status); | 159 // Japanese word break iteratos is identical to root with |
| 160 if(a && c){ | 160 // a dictionary-based break iterator, but Thai character break iterator |
| 161 if(*c==*a){ | 161 // is still different from Root. |
| 162 BreakIterator* c = BreakIterator::createCharacterInstance(Locale("ja"),statu
s); |
| 163 BreakIterator* d = BreakIterator::createCharacterInstance(Locale("th"),statu
s); |
| 164 if(c && d){ |
| 165 if(*c==*d){ |
| 162 errln("Failed: boilerplate method opertator== does not return correc
t results"); | 166 errln("Failed: boilerplate method opertator== does not return correc
t results"); |
| 163 } | 167 } |
| 164 }else{ | 168 }else{ |
| 165 errln("creation of break iterator failed"); | 169 errln("creation of break iterator failed"); |
| 166 } | 170 } |
| 167 delete a; | 171 delete a; |
| 168 delete b; | 172 delete b; |
| 169 delete c; | 173 delete c; |
| 174 delete d; |
| 170 } | 175 } |
| 171 | 176 |
| 172 void RBBIAPITest::TestgetRules() | 177 void RBBIAPITest::TestgetRules() |
| 173 { | 178 { |
| 174 UErrorCode status=U_ZERO_ERROR; | 179 UErrorCode status=U_ZERO_ERROR; |
| 175 | 180 |
| 176 RuleBasedBreakIterator* bi1=(RuleBasedBreakIterator*)RuleBasedBreakIterator:
:createCharacterInstance(Locale::getDefault(), status); | 181 RuleBasedBreakIterator* bi1=(RuleBasedBreakIterator*)RuleBasedBreakIterator:
:createCharacterInstance(Locale::getDefault(), status); |
| 177 RuleBasedBreakIterator* bi2=(RuleBasedBreakIterator*)RuleBasedBreakIterator:
:createWordInstance(Locale::getDefault(), status); | 182 RuleBasedBreakIterator* bi2=(RuleBasedBreakIterator*)RuleBasedBreakIterator:
:createWordInstance(Locale::getDefault(), status); |
| 178 if(U_FAILURE(status)){ | 183 if(U_FAILURE(status)){ |
| 179 errcheckln(status, "FAIL: in construction - %s", u_errorName(status)); | 184 errcheckln(status, "FAIL: in construction - %s", u_errorName(status)); |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 } | 633 } |
| 629 delete bi; | 634 delete bi; |
| 630 } | 635 } |
| 631 | 636 |
| 632 // | 637 // |
| 633 // TestRuleStatus | 638 // TestRuleStatus |
| 634 // Test word break rule status constants. | 639 // Test word break rule status constants. |
| 635 // | 640 // |
| 636 void RBBIAPITest::TestRuleStatus() { | 641 void RBBIAPITest::TestRuleStatus() { |
| 637 UChar str[30]; | 642 UChar str[30]; |
| 638 u_unescape("plain word 123.45 \\u9160\\u9161 \\u30a1\\u30a2 \\u3041\\u3094"
, | 643 //no longer test Han or hiragana breaking here: ruleStatusVec would return
nothing |
| 639 // 012345678901234567 8 9 0 1 2 3 4 5 6 | 644 // changed UBRK_WORD_KANA to UBRK_WORD_IDEO |
| 640 // Ideographic Katakana Hiragana | 645 u_unescape("plain word 123.45 \\u30a1\\u30a2 ", |
| 646 // 012345678901234567 8 9 0 |
| 647 // Katakana |
| 641 str, 30); | 648 str, 30); |
| 642 UnicodeString testString1(str); | 649 UnicodeString testString1(str); |
| 643 int32_t bounds1[] = {0, 5, 6, 10, 11, 17, 18, 19, 20, 21, 23, 24, 25, 26}; | 650 int32_t bounds1[] = {0, 5, 6, 10, 11, 17, 18, 20, 21}; |
| 644 int32_t tag_lo[] = {UBRK_WORD_NONE, UBRK_WORD_LETTER, UBRK_WORD_NONE,
UBRK_WORD_LETTER, | 651 int32_t tag_lo[] = {UBRK_WORD_NONE, UBRK_WORD_LETTER, UBRK_WORD_NONE,
UBRK_WORD_LETTER, |
| 645 UBRK_WORD_NONE, UBRK_WORD_NUMBER, UBRK_WORD_NONE, | 652 UBRK_WORD_NONE, UBRK_WORD_NUMBER, UBRK_WORD_NONE, |
| 646 UBRK_WORD_IDEO, UBRK_WORD_IDEO, UBRK_WORD_NONE, | 653 UBRK_WORD_IDEO, UBRK_WORD_NONE}; |
| 647 UBRK_WORD_KANA, UBRK_WORD_NONE, UBRK_WORD_KANA,
UBRK_WORD_KANA}; | |
| 648 | 654 |
| 649 int32_t tag_hi[] = {UBRK_WORD_NONE_LIMIT, UBRK_WORD_LETTER_LIMIT, UBRK_WOR
D_NONE_LIMIT, UBRK_WORD_LETTER_LIMIT, | 655 int32_t tag_hi[] = {UBRK_WORD_NONE_LIMIT, UBRK_WORD_LETTER_LIMIT, UBRK_WOR
D_NONE_LIMIT, UBRK_WORD_LETTER_LIMIT, |
| 650 UBRK_WORD_NONE_LIMIT, UBRK_WORD_NUMBER_LIMIT, UBRK_WOR
D_NONE_LIMIT, | 656 UBRK_WORD_NONE_LIMIT, UBRK_WORD_NUMBER_LIMIT, UBRK_WOR
D_NONE_LIMIT, |
| 651 UBRK_WORD_IDEO_LIMIT, UBRK_WORD_IDEO_LIMIT, UBRK_WOR
D_NONE_LIMIT, | 657 UBRK_WORD_IDEO_LIMIT, UBRK_WORD_NONE_LIMIT}; |
| 652 UBRK_WORD_KANA_LIMIT, UBRK_WORD_NONE_LIMIT, UBRK_WOR
D_KANA_LIMIT, UBRK_WORD_KANA_LIMIT}; | |
| 653 | 658 |
| 654 UErrorCode status=U_ZERO_ERROR; | 659 UErrorCode status=U_ZERO_ERROR; |
| 655 | 660 |
| 656 RuleBasedBreakIterator *bi = (RuleBasedBreakIterator *)BreakIterator::creat
eWordInstance(Locale::getEnglish(), status); | 661 RuleBasedBreakIterator *bi = (RuleBasedBreakIterator *)BreakIterator::creat
eWordInstance(Locale::getEnglish(), status); |
| 657 if(U_FAILURE(status)) { | 662 if(U_FAILURE(status)) { |
| 658 errcheckln(status, "Fail : in construction - %s", u_errorName(status)); | 663 errcheckln(status, "Fail : in construction - %s", u_errorName(status)); |
| 659 } else { | 664 } else { |
| 660 bi->setText(testString1); | 665 bi->setText(testString1); |
| 661 // First test that the breaks are in the right spots. | 666 // First test that the breaks are in the right spots. |
| 662 doBoundaryTest(*bi, testString1, bounds1); | 667 doBoundaryTest(*bi, testString1, bounds1); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 delete ja_word; | 886 delete ja_word; |
| 882 delete ja_char; | 887 delete ja_char; |
| 883 delete root_word; | 888 delete root_word; |
| 884 delete root_char; | 889 delete root_char; |
| 885 | 890 |
| 886 return; | 891 return; |
| 887 } | 892 } |
| 888 | 893 |
| 889 URegistryKey key = BreakIterator::registerInstance(ja_word, "xx", UBRK_WORD,
status); | 894 URegistryKey key = BreakIterator::registerInstance(ja_word, "xx", UBRK_WORD,
status); |
| 890 { | 895 { |
| 896 #if 0 // With a dictionary based word breaking, ja_word is identical to root. |
| 891 if (ja_word && *ja_word == *root_word) { | 897 if (ja_word && *ja_word == *root_word) { |
| 892 errln("japan not different from root"); | 898 errln("japan not different from root"); |
| 893 } | 899 } |
| 900 #endif |
| 894 } | 901 } |
| 895 | 902 |
| 896 { | 903 { |
| 897 BreakIterator* result = BreakIterator::createWordInstance("xx_XX", statu
s); | 904 BreakIterator* result = BreakIterator::createWordInstance("xx_XX", statu
s); |
| 898 UBool fail = TRUE; | 905 UBool fail = TRUE; |
| 899 if(result){ | 906 if(result){ |
| 900 fail = *result != *ja_word; | 907 fail = *result != *ja_word; |
| 901 } | 908 } |
| 902 delete result; | 909 delete result; |
| 903 if (fail) { | 910 if (fail) { |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 : RuleBasedBreakIterator(data, status) | 1184 : RuleBasedBreakIterator(data, status) |
| 1178 { | 1185 { |
| 1179 } | 1186 } |
| 1180 | 1187 |
| 1181 RBBIWithProtectedFunctions::RBBIWithProtectedFunctions(const RBBIDataHeader* dat
a, enum EDontAdopt, UErrorCode &status) | 1188 RBBIWithProtectedFunctions::RBBIWithProtectedFunctions(const RBBIDataHeader* dat
a, enum EDontAdopt, UErrorCode &status) |
| 1182 : RuleBasedBreakIterator(data, RuleBasedBreakIterator::kDontAdopt, status) | 1189 : RuleBasedBreakIterator(data, RuleBasedBreakIterator::kDontAdopt, status) |
| 1183 { | 1190 { |
| 1184 } | 1191 } |
| 1185 | 1192 |
| 1186 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ | 1193 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ |
| OLD | NEW |