Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: source/test/intltest/rbbiapts.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/test/intltest/rbbiapts.h ('k') | source/test/intltest/rbbitst.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /******************************************************************** 1 /********************************************************************
2 * Copyright (c) 1999-2013, International Business Machines 2 * Copyright (c) 1999-2014, 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"
11 11
12 #if !UCONFIG_NO_BREAK_ITERATION 12 #if !UCONFIG_NO_BREAK_ITERATION
13 13
14 #include "unicode/uchar.h" 14 #include "unicode/uchar.h"
15 #include "intltest.h" 15 #include "intltest.h"
16 #include "unicode/rbbi.h" 16 #include "unicode/rbbi.h"
17 #include "unicode/schriter.h" 17 #include "unicode/schriter.h"
18 #include "rbbiapts.h" 18 #include "rbbiapts.h"
19 #include "rbbidata.h" 19 #include "rbbidata.h"
20 #include "cstring.h" 20 #include "cstring.h"
21 #include "ubrkimpl.h" 21 #include "ubrkimpl.h"
22 #include "unicode/locid.h" 22 #include "unicode/locid.h"
23 #include "unicode/ustring.h" 23 #include "unicode/ustring.h"
24 #include "unicode/utext.h" 24 #include "unicode/utext.h"
25 #include "cmemory.h" 25 #include "cmemory.h"
26 26 #if !UCONFIG_NO_BREAK_ITERATION && U_HAVE_STD_STRING
27 #include "unicode/filteredbrk.h"
28 #include <stdio.h> // for sprintf
29 #endif
27 /** 30 /**
28 * API Test the RuleBasedBreakIterator class 31 * API Test the RuleBasedBreakIterator class
29 */ 32 */
30 33
31 34
32 #define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) {\ 35 #define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) {\
33 dataerrln("Failure at file %s, line %d, error = %s", __FILE__, __LINE__, u_error Name(status));}} 36 dataerrln("Failure at file %s, line %d, error = %s", __FILE__, __LINE__, u_error Name(status));}}
34 37
35 #define TEST_ASSERT(expr) {if ((expr) == FALSE) { \ 38 #define TEST_ASSERT(expr) {if ((expr) == FALSE) { \
36 errln("Test Failure at file %s, line %d: \"%s\" is false.\n", __FILE__, __LI NE__, #expr);};} 39 errln("Test Failure at file %s, line %d: \"%s\" is false.\n", __FILE__, __LI NE__, #expr);};}
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 639
637 // 640 //
638 // TestRuleStatus 641 // TestRuleStatus
639 // Test word break rule status constants. 642 // Test word break rule status constants.
640 // 643 //
641 void RBBIAPITest::TestRuleStatus() { 644 void RBBIAPITest::TestRuleStatus() {
642 UChar str[30]; 645 UChar str[30];
643 //no longer test Han or hiragana breaking here: ruleStatusVec would return nothing 646 //no longer test Han or hiragana breaking here: ruleStatusVec would return nothing
644 // changed UBRK_WORD_KANA to UBRK_WORD_IDEO 647 // changed UBRK_WORD_KANA to UBRK_WORD_IDEO
645 u_unescape("plain word 123.45 \\u30a1\\u30a2 ", 648 u_unescape("plain word 123.45 \\u30a1\\u30a2 ",
646 // 012345678901234567 8 9 0 649 // 012345678901234567 8 9 0
647 // Katakana 650 // Katakana
648 str, 30); 651 str, 30);
649 UnicodeString testString1(str); 652 UnicodeString testString1(str);
650 int32_t bounds1[] = {0, 5, 6, 10, 11, 17, 18, 20, 21}; 653 int32_t bounds1[] = {0, 5, 6, 10, 11, 17, 18, 20, 21};
651 int32_t tag_lo[] = {UBRK_WORD_NONE, UBRK_WORD_LETTER, UBRK_WORD_NONE, UBRK_WORD_LETTER, 654 int32_t tag_lo[] = {UBRK_WORD_NONE, UBRK_WORD_LETTER, UBRK_WORD_NONE, UBRK_WORD_LETTER,
652 UBRK_WORD_NONE, UBRK_WORD_NUMBER, UBRK_WORD_NONE, 655 UBRK_WORD_NONE, UBRK_WORD_NUMBER, UBRK_WORD_NONE,
653 UBRK_WORD_IDEO, UBRK_WORD_NONE}; 656 UBRK_WORD_IDEO, UBRK_WORD_NONE};
654 657
655 int32_t tag_hi[] = {UBRK_WORD_NONE_LIMIT, UBRK_WORD_LETTER_LIMIT, UBRK_WOR D_NONE_LIMIT, UBRK_WORD_LETTER_LIMIT, 658 int32_t tag_hi[] = {UBRK_WORD_NONE_LIMIT, UBRK_WORD_LETTER_LIMIT, UBRK_WOR D_NONE_LIMIT, UBRK_WORD_LETTER_LIMIT,
656 UBRK_WORD_NONE_LIMIT, UBRK_WORD_NUMBER_LIMIT, UBRK_WOR D_NONE_LIMIT, 659 UBRK_WORD_NONE_LIMIT, UBRK_WORD_NUMBER_LIMIT, UBRK_WOR D_NONE_LIMIT,
657 UBRK_WORD_IDEO_LIMIT, UBRK_WORD_NONE_LIMIT}; 660 UBRK_WORD_IDEO_LIMIT, UBRK_WORD_NONE_LIMIT};
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 874
872 875
873 void RBBIAPITest::TestRegistration() { 876 void RBBIAPITest::TestRegistration() {
874 #if !UCONFIG_NO_SERVICE 877 #if !UCONFIG_NO_SERVICE
875 UErrorCode status = U_ZERO_ERROR; 878 UErrorCode status = U_ZERO_ERROR;
876 BreakIterator* ja_word = BreakIterator::createWordInstance("ja_JP", status); 879 BreakIterator* ja_word = BreakIterator::createWordInstance("ja_JP", status);
877 // ok to not delete these if we exit because of error? 880 // ok to not delete these if we exit because of error?
878 BreakIterator* ja_char = BreakIterator::createCharacterInstance("ja_JP", sta tus); 881 BreakIterator* ja_char = BreakIterator::createCharacterInstance("ja_JP", sta tus);
879 BreakIterator* root_word = BreakIterator::createWordInstance("", status); 882 BreakIterator* root_word = BreakIterator::createWordInstance("", status);
880 BreakIterator* root_char = BreakIterator::createCharacterInstance("", status ); 883 BreakIterator* root_char = BreakIterator::createCharacterInstance("", status );
881 884
882 if (status == U_MISSING_RESOURCE_ERROR || status == U_FILE_ACCESS_ERROR) { 885 if (status == U_MISSING_RESOURCE_ERROR || status == U_FILE_ACCESS_ERROR) {
883 dataerrln("Error creating instances of break interactors - %s", u_errorN ame(status)); 886 dataerrln("Error creating instances of break interactors - %s", u_errorN ame(status));
884 887
885 delete ja_word; 888 delete ja_word;
886 delete ja_char; 889 delete ja_char;
887 delete root_word; 890 delete root_word;
888 delete root_char; 891 delete root_char;
889 892
890 return; 893 return;
891 } 894 }
892 895
893 URegistryKey key = BreakIterator::registerInstance(ja_word, "xx", UBRK_WORD, status); 896 URegistryKey key = BreakIterator::registerInstance(ja_word, "xx", UBRK_WORD, status);
894 { 897 {
895 #if 0 // With a dictionary based word breaking, ja_word is identical to root. 898 #if 0 // With a dictionary based word breaking, ja_word is identical to root.
896 if (ja_word && *ja_word == *root_word) { 899 if (ja_word && *ja_word == *root_word) {
897 errln("japan not different from root"); 900 errln("japan not different from root");
898 } 901 }
899 #endif 902 #endif
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 RoundtripRule("sent"); 1053 RoundtripRule("sent");
1051 RoundtripRule("line"); 1054 RoundtripRule("line");
1052 RoundtripRule("char"); 1055 RoundtripRule("char");
1053 if (!quick) { 1056 if (!quick) {
1054 RoundtripRule("word_POSIX"); 1057 RoundtripRule("word_POSIX");
1055 } 1058 }
1056 } 1059 }
1057 1060
1058 // Try out the RuleBasedBreakIterator constructors that take RBBIDataHeader* 1061 // Try out the RuleBasedBreakIterator constructors that take RBBIDataHeader*
1059 // (these are protected so we access them via a local class RBBIWithProtectedFun ctions). 1062 // (these are protected so we access them via a local class RBBIWithProtectedFun ctions).
1060 // This is just a sanity check, not a thorough test (e.g. we don't check that th e 1063 // This is just a sanity check, not a thorough test (e.g. we don't check that th e
1061 // first delete actually frees rulesCopy). 1064 // first delete actually frees rulesCopy).
1062 void RBBIAPITest::TestCreateFromRBBIData() { 1065 void RBBIAPITest::TestCreateFromRBBIData() {
1063 // Get some handy RBBIData 1066 // Get some handy RBBIData
1064 const char *brkName = "word"; // or "sent", "line", "char", etc. 1067 const char *brkName = "word"; // or "sent", "line", "char", etc.
1065 UErrorCode status = U_ZERO_ERROR; 1068 UErrorCode status = U_ZERO_ERROR;
1066 LocalUDataMemoryPointer data(udata_open(U_ICUDATA_BRKITR, "brk", brkName, &s tatus)); 1069 LocalUDataMemoryPointer data(udata_open(U_ICUDATA_BRKITR, "brk", brkName, &s tatus));
1067 if ( U_SUCCESS(status) ) { 1070 if ( U_SUCCESS(status) ) {
1068 const RBBIDataHeader * builtRules = (const RBBIDataHeader *)udata_getMem ory(data.getAlias()); 1071 const RBBIDataHeader * builtRules = (const RBBIDataHeader *)udata_getMem ory(data.getAlias());
1069 uint32_t length = builtRules->fLength; 1072 uint32_t length = builtRules->fLength;
1070 RBBIWithProtectedFunctions * brkItr; 1073 RBBIWithProtectedFunctions * brkItr;
1071 1074
1072 // Try the memory-adopting constructor, need to copy the data first 1075 // Try the memory-adopting constructor, need to copy the data first
1073 RBBIDataHeader * rulesCopy = (RBBIDataHeader *) uprv_malloc(length); 1076 RBBIDataHeader * rulesCopy = (RBBIDataHeader *) uprv_malloc(length);
1074 if ( rulesCopy ) { 1077 if ( rulesCopy ) {
1075 uprv_memcpy( rulesCopy, builtRules, length ); 1078 uprv_memcpy( rulesCopy, builtRules, length );
1076 1079
1077 brkItr = new RBBIWithProtectedFunctions(rulesCopy, status); 1080 brkItr = new RBBIWithProtectedFunctions(rulesCopy, status);
1078 if ( U_SUCCESS(status) ) { 1081 if ( U_SUCCESS(status) ) {
1079 delete brkItr; // this should free rulesCopy 1082 delete brkItr; // this should free rulesCopy
1080 } else { 1083 } else {
1081 errln("create RuleBasedBreakIterator from RBBIData (adopted): IC U Error \"%s\"\n", u_errorName(status) ); 1084 errln("create RuleBasedBreakIterator from RBBIData (adopted): IC U Error \"%s\"\n", u_errorName(status) );
1082 status = U_ZERO_ERROR;// reset for the next test 1085 status = U_ZERO_ERROR;// reset for the next test
1083 uprv_free( rulesCopy ); 1086 uprv_free( rulesCopy );
1084 } 1087 }
1085 } 1088 }
1086 1089
1087 // Now try the non-adopting constructor 1090 // Now try the non-adopting constructor
1088 brkItr = new RBBIWithProtectedFunctions(builtRules, RBBIWithProtectedFun ctions::kDontAdopt, status); 1091 brkItr = new RBBIWithProtectedFunctions(builtRules, RBBIWithProtectedFun ctions::kDontAdopt, status);
1089 if ( U_SUCCESS(status) ) { 1092 if ( U_SUCCESS(status) ) {
1090 delete brkItr; // this should NOT attempt to free builtRules 1093 delete brkItr; // this should NOT attempt to free builtRules
1091 if (builtRules->fLength != length) { // sanity check 1094 if (builtRules->fLength != length) { // sanity check
1092 errln("create RuleBasedBreakIterator from RBBIData (non-adopted) : delete affects data\n" ); 1095 errln("create RuleBasedBreakIterator from RBBIData (non-adopted) : delete affects data\n" );
1093 } 1096 }
1094 } else { 1097 } else {
1095 errln("create RuleBasedBreakIterator from RBBIData (non-adopted): IC U Error \"%s\"\n", u_errorName(status) ); 1098 errln("create RuleBasedBreakIterator from RBBIData (non-adopted): IC U Error \"%s\"\n", u_errorName(status) );
1096 } 1099 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 TEST_ASSERT_SUCCESS(status); 1164 TEST_ASSERT_SUCCESS(status);
1162 RuleBasedBreakIterator *returnedBI = &bi->refreshInputText(&ut2, status) ; 1165 RuleBasedBreakIterator *returnedBI = &bi->refreshInputText(&ut2, status) ;
1163 TEST_ASSERT_SUCCESS(status); 1166 TEST_ASSERT_SUCCESS(status);
1164 TEST_ASSERT(bi == returnedBI); 1167 TEST_ASSERT(bi == returnedBI);
1165 1168
1166 /* Find the following matches, now working in the moved string. */ 1169 /* Find the following matches, now working in the moved string. */
1167 TEST_ASSERT(5 == bi->next()); 1170 TEST_ASSERT(5 == bi->next());
1168 TEST_ASSERT(7 == bi->next()); 1171 TEST_ASSERT(7 == bi->next());
1169 TEST_ASSERT(8 == bi->next()); 1172 TEST_ASSERT(8 == bi->next());
1170 TEST_ASSERT(UBRK_DONE == bi->next()); 1173 TEST_ASSERT(UBRK_DONE == bi->next());
1171 1174
1172 utext_close(&ut1); 1175 utext_close(&ut1);
1173 utext_close(&ut2); 1176 utext_close(&ut2);
1174 } 1177 }
1175 delete bi; 1178 delete bi;
1176 1179
1177 } 1180 }
1178 1181
1182 #if !UCONFIG_NO_BREAK_ITERATION && U_HAVE_STD_STRING && !UCONFIG_NO_FILTERED_BRE AK_ITERATION
1183 static void prtbrks(BreakIterator* brk, const UnicodeString &ustr, IntlTest &it) {
1184 static const UChar PILCROW=0x00B6, CHSTR=0x3010, CHEND=0x3011; // lenticular b rackets
1185 it.logln(UnicodeString("String:'")+ustr+UnicodeString("'"));
1186
1187 int32_t *pos = new int32_t[ustr.length()];
1188 int32_t posCount = 0;
1189
1190 // calculate breaks up front, so we can print out
1191 // sans any debugging
1192 for(int32_t n = 0; (n=brk->next())!=UBRK_DONE; ) {
1193 pos[posCount++] = n;
1194 if(posCount>=ustr.length()) {
1195 it.errln("brk count exceeds string length!");
1196 return;
1197 }
1198 }
1199 UnicodeString out;
1200 out.append((UChar)CHSTR);
1201 int32_t prev = 0;
1202 for(int32_t i=0;i<posCount;i++) {
1203 int32_t n=pos[i];
1204 out.append(ustr.tempSubString(prev,n-prev));
1205 out.append((UChar)PILCROW);
1206 prev=n;
1207 }
1208 out.append(ustr.tempSubString(prev,ustr.length()-prev));
1209 out.append((UChar)CHEND);
1210 it.logln(out);
1211
1212 out.remove();
1213 for(int32_t i=0;i<posCount;i++) {
1214 char tmp[100];
1215 sprintf(tmp,"%d ",pos[i]);
1216 out.append(UnicodeString(tmp));
1217 }
1218 it.logln(out);
1219 delete [] pos;
1220 }
1221 #endif
1222
1223 void RBBIAPITest::TestFilteredBreakIteratorBuilder() {
1224 #if !UCONFIG_NO_BREAK_ITERATION && U_HAVE_STD_STRING && !UCONFIG_NO_FILTERED_BRE AK_ITERATION
1225 UErrorCode status = U_ZERO_ERROR;
1226 LocalPointer<FilteredBreakIteratorBuilder> builder;
1227 LocalPointer<BreakIterator> baseBI;
1228 LocalPointer<BreakIterator> filteredBI;
1229
1230 const UnicodeString text("In the meantime Mr. Weston arrived with his small sh ip, which he had now recovered. Capt. Gorges, who informed the Sgt. here that on e purpose of his going east was to meet with Mr. Weston, took this opportunity t o call him to account for some abuses he had to lay to his charge."); // (Willia m Bradford, public domain. http://catalog.hathitrust.org/Record/008651224 ) - ed ited.
1231 const UnicodeString ABBR_MR("Mr.");
1232 const UnicodeString ABBR_CAPT("Capt.");
1233
1234 {
1235 logln("Constructing empty builder\n");
1236 builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(status));
1237 TEST_ASSERT_SUCCESS(status);
1238
1239 logln("Constructing base BI\n");
1240 baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish (), status));
1241 TEST_ASSERT_SUCCESS(status);
1242
1243 logln("Building new BI\n");
1244 filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
1245 TEST_ASSERT_SUCCESS(status);
1246
1247 if (U_SUCCESS(status)) {
1248 logln("Testing:");
1249 filteredBI->setText(text);
1250 TEST_ASSERT(20 == filteredBI->next()); // Mr.
1251 TEST_ASSERT(84 == filteredBI->next()); // recovered.
1252 TEST_ASSERT(90 == filteredBI->next()); // Capt.
1253 TEST_ASSERT(181 == filteredBI->next()); // Mr.
1254 TEST_ASSERT(278 == filteredBI->next()); // charge.
1255 filteredBI->first();
1256 prtbrks(filteredBI.getAlias(), text, *this);
1257 }
1258 }
1259
1260 {
1261 logln("Constructing empty builder\n");
1262 builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(status));
1263 TEST_ASSERT_SUCCESS(status);
1264
1265 if (U_SUCCESS(status)) {
1266 logln("Adding Mr. as an exception\n");
1267 TEST_ASSERT(TRUE == builder->suppressBreakAfter(ABBR_MR, status));
1268 TEST_ASSERT(FALSE == builder->suppressBreakAfter(ABBR_MR, status)); // a lready have it
1269 TEST_ASSERT(TRUE == builder->unsuppressBreakAfter(ABBR_MR, status));
1270 TEST_ASSERT(FALSE == builder->unsuppressBreakAfter(ABBR_MR, status)); // already removed it
1271 TEST_ASSERT(TRUE == builder->suppressBreakAfter(ABBR_MR, status));
1272 TEST_ASSERT_SUCCESS(status);
1273
1274 logln("Constructing base BI\n");
1275 baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEng lish(), status));
1276 TEST_ASSERT_SUCCESS(status);
1277
1278 logln("Building new BI\n");
1279 filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
1280 TEST_ASSERT_SUCCESS(status);
1281
1282 logln("Testing:");
1283 filteredBI->setText(text);
1284 TEST_ASSERT(84 == filteredBI->next());
1285 TEST_ASSERT(90 == filteredBI->next());// Capt.
1286 TEST_ASSERT(278 == filteredBI->next());
1287 filteredBI->first();
1288 prtbrks(filteredBI.getAlias(), text, *this);
1289 }
1290 }
1291
1292
1293 {
1294 logln("Constructing empty builder\n");
1295 builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(status));
1296 TEST_ASSERT_SUCCESS(status);
1297
1298 if (U_SUCCESS(status)) {
1299 logln("Adding Mr. and Capt as an exception\n");
1300 TEST_ASSERT(TRUE == builder->suppressBreakAfter(ABBR_MR, status));
1301 TEST_ASSERT(TRUE == builder->suppressBreakAfter(ABBR_CAPT, status));
1302 TEST_ASSERT_SUCCESS(status);
1303
1304 logln("Constructing base BI\n");
1305 baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEng lish(), status));
1306 TEST_ASSERT_SUCCESS(status);
1307
1308 logln("Building new BI\n");
1309 filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
1310 TEST_ASSERT_SUCCESS(status);
1311
1312 logln("Testing:");
1313 filteredBI->setText(text);
1314 TEST_ASSERT(84 == filteredBI->next());
1315 TEST_ASSERT(278 == filteredBI->next());
1316 filteredBI->first();
1317 prtbrks(filteredBI.getAlias(), text, *this);
1318 }
1319 }
1320
1321
1322 {
1323 logln("Constructing English builder\n");
1324 builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(Locale::ge tEnglish(), status));
1325 TEST_ASSERT_SUCCESS(status);
1326
1327 logln("Constructing base BI\n");
1328 baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish (), status));
1329 TEST_ASSERT_SUCCESS(status);
1330
1331 if (U_SUCCESS(status)) {
1332 logln("unsuppressing 'Capt'");
1333 TEST_ASSERT(TRUE == builder->unsuppressBreakAfter(ABBR_CAPT, status));
1334
1335 logln("Building new BI\n");
1336 filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
1337 TEST_ASSERT_SUCCESS(status);
1338
1339 if(filteredBI.isValid()) {
1340 logln("Testing:");
1341 filteredBI->setText(text);
1342 TEST_ASSERT(84 == filteredBI->next());
1343 TEST_ASSERT(90 == filteredBI->next());
1344 TEST_ASSERT(278 == filteredBI->next());
1345 filteredBI->first();
1346 prtbrks(filteredBI.getAlias(), text, *this);
1347 }
1348 }
1349 }
1350
1351
1352 {
1353 logln("Constructing English builder\n");
1354 builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(Locale::ge tEnglish(), status));
1355 TEST_ASSERT_SUCCESS(status);
1356
1357 logln("Constructing base BI\n");
1358 baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish (), status));
1359 TEST_ASSERT_SUCCESS(status);
1360
1361 if (U_SUCCESS(status)) {
1362 logln("Building new BI\n");
1363 filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
1364 TEST_ASSERT_SUCCESS(status);
1365
1366 if(filteredBI.isValid()) {
1367 logln("Testing:");
1368 filteredBI->setText(text);
1369 TEST_ASSERT(84 == filteredBI->next());
1370 TEST_ASSERT(278 == filteredBI->next());
1371 filteredBI->first();
1372 prtbrks(filteredBI.getAlias(), text, *this);
1373 }
1374 }
1375 }
1376
1377 #if 0
1378 // reenable once french is in
1379 {
1380 logln("Constructing French builder");
1381 builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(Locale::ge tFrench(), status));
1382 TEST_ASSERT_SUCCESS(status);
1383
1384 logln("Constructing base BI\n");
1385 baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getFrench( ), status));
1386 TEST_ASSERT_SUCCESS(status);
1387
1388 logln("Building new BI\n");
1389 filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
1390 TEST_ASSERT_SUCCESS(status);
1391
1392 if(filteredBI.isValid()) {
1393 logln("Testing:");
1394 filteredBI->setText(text);
1395 TEST_ASSERT(20 == filteredBI->next());
1396 TEST_ASSERT(84 == filteredBI->next());
1397 filteredBI->first();
1398 prtbrks(filteredBI.getAlias(), text, *this);
1399 }
1400 }
1401 #endif
1402
1403 #else
1404 logln("Skipped- not: !UCONFIG_NO_BREAK_ITERATION && U_HAVE_STD_STRING && !UCON FIG_NO_FILTERED_BREAK_ITERATION");
1405 #endif
1406 }
1179 1407
1180 //--------------------------------------------- 1408 //---------------------------------------------
1181 // runIndexedTest 1409 // runIndexedTest
1182 //--------------------------------------------- 1410 //---------------------------------------------
1183 1411
1184 void RBBIAPITest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ ) 1412 void RBBIAPITest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
1185 { 1413 {
1186 if (exec) logln((UnicodeString)"TestSuite RuleBasedBreakIterator API "); 1414 if (exec) logln((UnicodeString)"TestSuite RuleBasedBreakIterator API ");
1187 switch (index) { 1415 switch (index) {
1188 // case 0: name = "TestConstruction"; if (exec) TestConstruction(); break ; 1416 // case 0: name = "TestConstruction"; if (exec) TestConstruction(); break ;
(...skipping 14 matching lines...) Expand all
1203 case 9: name = "TestRegistration"; if (exec) TestRegistration(); break; 1431 case 9: name = "TestRegistration"; if (exec) TestRegistration(); break;
1204 case 10: name = "TestBoilerPlate"; if (exec) TestBoilerPlate(); break; 1432 case 10: name = "TestBoilerPlate"; if (exec) TestBoilerPlate(); break;
1205 case 11: name = "TestRuleStatus"; if (exec) TestRuleStatus(); break; 1433 case 11: name = "TestRuleStatus"; if (exec) TestRuleStatus(); break;
1206 case 12: name = "TestRoundtripRules"; if (exec) TestRoundtripRules(); br eak; 1434 case 12: name = "TestRoundtripRules"; if (exec) TestRoundtripRules(); br eak;
1207 case 13: name = "TestCreateFromRBBIData"; if (exec) TestCreateFromRBBIDa ta(); break; 1435 case 13: name = "TestCreateFromRBBIData"; if (exec) TestCreateFromRBBIDa ta(); break;
1208 #else 1436 #else
1209 case 9: case 10: case 11: case 12: case 13: name = "skip"; break; 1437 case 9: case 10: case 11: case 12: case 13: name = "skip"; break;
1210 #endif 1438 #endif
1211 case 14: name = "TestRefreshInputText"; if (exec) TestRefreshInputText() ; break; 1439 case 14: name = "TestRefreshInputText"; if (exec) TestRefreshInputText() ; break;
1212 1440
1441 #if !UCONFIG_NO_BREAK_ITERATION && U_HAVE_STD_STRING
1442 case 15: name = "TestFilteredBreakIteratorBuilder"; if(exec) TestFilteredBre akIteratorBuilder(); break;
1443 #else
1444 case 15: name="skip"; break;
1445 #endif
1213 default: name = ""; break; // needed to end loop 1446 default: name = ""; break; // needed to end loop
1214 } 1447 }
1215 } 1448 }
1216 1449
1217 //--------------------------------------------- 1450 //---------------------------------------------
1218 //Internal subroutines 1451 //Internal subroutines
1219 //--------------------------------------------- 1452 //---------------------------------------------
1220 1453
1221 void RBBIAPITest::doBoundaryTest(BreakIterator& bi, UnicodeString& text, int32_t *boundaries){ 1454 void RBBIAPITest::doBoundaryTest(BreakIterator& bi, UnicodeString& text, int32_t *boundaries){
1222 logln((UnicodeString)"testIsBoundary():"); 1455 logln((UnicodeString)"testIsBoundary():");
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 : RuleBasedBreakIterator(data, status) 1496 : RuleBasedBreakIterator(data, status)
1264 { 1497 {
1265 } 1498 }
1266 1499
1267 RBBIWithProtectedFunctions::RBBIWithProtectedFunctions(const RBBIDataHeader* dat a, enum EDontAdopt, UErrorCode &status) 1500 RBBIWithProtectedFunctions::RBBIWithProtectedFunctions(const RBBIDataHeader* dat a, enum EDontAdopt, UErrorCode &status)
1268 : RuleBasedBreakIterator(data, RuleBasedBreakIterator::kDontAdopt, status) 1501 : RuleBasedBreakIterator(data, RuleBasedBreakIterator::kDontAdopt, status)
1269 { 1502 {
1270 } 1503 }
1271 1504
1272 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ 1505 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
OLDNEW
« no previous file with comments | « source/test/intltest/rbbiapts.h ('k') | source/test/intltest/rbbitst.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698