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

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

Issue 1191653011: icu: Merge http://bugs.icu-project.org/trac/changeset/36672 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: Created 5 years, 6 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/i18n/filteredbrk.cpp ('k') | no next file » | 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-2014, 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"
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 delete [] pos; 1219 delete [] pos;
1220 } 1220 }
1221 #endif 1221 #endif
1222 1222
1223 void RBBIAPITest::TestFilteredBreakIteratorBuilder() { 1223 void RBBIAPITest::TestFilteredBreakIteratorBuilder() {
1224 #if !UCONFIG_NO_BREAK_ITERATION && U_HAVE_STD_STRING && !UCONFIG_NO_FILTERED_BRE AK_ITERATION 1224 #if !UCONFIG_NO_BREAK_ITERATION && U_HAVE_STD_STRING && !UCONFIG_NO_FILTERED_BRE AK_ITERATION
1225 UErrorCode status = U_ZERO_ERROR; 1225 UErrorCode status = U_ZERO_ERROR;
1226 LocalPointer<FilteredBreakIteratorBuilder> builder; 1226 LocalPointer<FilteredBreakIteratorBuilder> builder;
1227 LocalPointer<BreakIterator> baseBI; 1227 LocalPointer<BreakIterator> baseBI;
1228 LocalPointer<BreakIterator> filteredBI; 1228 LocalPointer<BreakIterator> filteredBI;
1229 LocalPointer<BreakIterator> frenchBI;
1229 1230
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 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_MR("Mr.");
1232 const UnicodeString ABBR_CAPT("Capt."); 1233 const UnicodeString ABBR_CAPT("Capt.");
1233 1234
1234 { 1235 {
1235 logln("Constructing empty builder\n"); 1236 logln("Constructing empty builder\n");
1236 builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(status)); 1237 builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(status));
1237 TEST_ASSERT_SUCCESS(status); 1238 TEST_ASSERT_SUCCESS(status);
1238 1239
1239 logln("Constructing base BI\n"); 1240 logln("Constructing base BI\n");
1240 baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish (), status)); 1241 baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish (), status));
1241 TEST_ASSERT_SUCCESS(status); 1242 TEST_ASSERT_SUCCESS(status);
1242 1243
1243 logln("Building new BI\n"); 1244 » logln("Building new BI\n");
1244 filteredBI.adoptInstead(builder->build(baseBI.orphan(), status)); 1245 filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
1245 TEST_ASSERT_SUCCESS(status); 1246 TEST_ASSERT_SUCCESS(status);
1246 1247
1247 if (U_SUCCESS(status)) { 1248 » if (U_SUCCESS(status)) {
1248 logln("Testing:"); 1249 logln("Testing:");
1249 filteredBI->setText(text); 1250 filteredBI->setText(text);
1250 TEST_ASSERT(20 == filteredBI->next()); // Mr. 1251 TEST_ASSERT(20 == filteredBI->next()); // Mr.
1251 TEST_ASSERT(84 == filteredBI->next()); // recovered. 1252 TEST_ASSERT(84 == filteredBI->next()); // recovered.
1252 TEST_ASSERT(90 == filteredBI->next()); // Capt. 1253 TEST_ASSERT(90 == filteredBI->next()); // Capt.
1253 TEST_ASSERT(181 == filteredBI->next()); // Mr. 1254 TEST_ASSERT(181 == filteredBI->next()); // Mr.
1254 TEST_ASSERT(278 == filteredBI->next()); // charge. 1255 TEST_ASSERT(278 == filteredBI->next()); // charge.
1255 filteredBI->first(); 1256 filteredBI->first();
1256 prtbrks(filteredBI.getAlias(), text, *this); 1257 prtbrks(filteredBI.getAlias(), text, *this);
1257 } 1258 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 logln("Testing:"); 1368 logln("Testing:");
1368 filteredBI->setText(text); 1369 filteredBI->setText(text);
1369 TEST_ASSERT(84 == filteredBI->next()); 1370 TEST_ASSERT(84 == filteredBI->next());
1370 TEST_ASSERT(278 == filteredBI->next()); 1371 TEST_ASSERT(278 == filteredBI->next());
1371 filteredBI->first(); 1372 filteredBI->first();
1372 prtbrks(filteredBI.getAlias(), text, *this); 1373 prtbrks(filteredBI.getAlias(), text, *this);
1373 } 1374 }
1374 } 1375 }
1375 } 1376 }
1376 1377
1377 #if 0
1378 // reenable once french is in 1378 // reenable once french is in
1379 { 1379 {
1380 logln("Constructing French builder"); 1380 logln("Constructing French builder");
1381 builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(Locale::ge tFrench(), status)); 1381 builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(Locale::ge tFrench(), status));
1382 TEST_ASSERT_SUCCESS(status); 1382 TEST_ASSERT_SUCCESS(status);
1383 1383
1384 logln("Constructing base BI\n"); 1384 logln("Constructing base BI\n");
1385 baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getFrench( ), status)); 1385 baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getFrench( ), status));
1386 TEST_ASSERT_SUCCESS(status); 1386 TEST_ASSERT_SUCCESS(status);
1387 1387
1388 logln("Building new BI\n"); 1388 logln("Building new BI\n");
1389 filteredBI.adoptInstead(builder->build(baseBI.orphan(), status)); 1389 frenchBI.adoptInstead(builder->build(baseBI.orphan(), status));
1390 TEST_ASSERT_SUCCESS(status); 1390 TEST_ASSERT_SUCCESS(status);
1391 1391
1392 if(filteredBI.isValid()) { 1392 if(frenchBI.isValid()) {
1393 logln("Testing:"); 1393 logln("Testing:");
1394 filteredBI->setText(text); 1394 UnicodeString frText("C'est MM. Duval.");
1395 TEST_ASSERT(20 == filteredBI->next()); 1395 frenchBI->setText(frText);
1396 TEST_ASSERT(84 == filteredBI->next()); 1396 TEST_ASSERT(16 == frenchBI->next());
1397 TEST_ASSERT(BreakIterator::DONE == frenchBI->next());
1398 frenchBI->first();
1399 prtbrks(frenchBI.getAlias(), frText, *this);
1400 logln("Testing against English:");
1401 filteredBI->setText(frText);
1402 TEST_ASSERT(10 == filteredBI->next()); // wrong for french, but filterBI i s english.
1403 TEST_ASSERT(16 == filteredBI->next());
1404 TEST_ASSERT(BreakIterator::DONE == filteredBI->next());
1397 filteredBI->first(); 1405 filteredBI->first();
1398 prtbrks(filteredBI.getAlias(), text, *this); 1406 prtbrks(filteredBI.getAlias(), frText, *this);
1399 } 1407
1408 // Verify ==
1409 TEST_ASSERT_TRUE(*frenchBI == *frenchBI);
1410 TEST_ASSERT_TRUE(*filteredBI != *frenchBI);
1411 TEST_ASSERT_TRUE(*frenchBI != *filteredBI);
1412 } else {
1413 dataerrln("French BI: not valid.");
1414 » }
1400 } 1415 }
1401 #endif
1402 1416
1403 #else 1417 #else
1404 logln("Skipped- not: !UCONFIG_NO_BREAK_ITERATION && U_HAVE_STD_STRING && !UCON FIG_NO_FILTERED_BREAK_ITERATION"); 1418 logln("Skipped- not: !UCONFIG_NO_BREAK_ITERATION && U_HAVE_STD_STRING && !UCON FIG_NO_FILTERED_BREAK_ITERATION");
1405 #endif 1419 #endif
1406 } 1420 }
1407 1421
1408 //--------------------------------------------- 1422 //---------------------------------------------
1409 // runIndexedTest 1423 // runIndexedTest
1410 //--------------------------------------------- 1424 //---------------------------------------------
1411 1425
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 : RuleBasedBreakIterator(data, status) 1510 : RuleBasedBreakIterator(data, status)
1497 { 1511 {
1498 } 1512 }
1499 1513
1500 RBBIWithProtectedFunctions::RBBIWithProtectedFunctions(const RBBIDataHeader* dat a, enum EDontAdopt, UErrorCode &status) 1514 RBBIWithProtectedFunctions::RBBIWithProtectedFunctions(const RBBIDataHeader* dat a, enum EDontAdopt, UErrorCode &status)
1501 : RuleBasedBreakIterator(data, RuleBasedBreakIterator::kDontAdopt, status) 1515 : RuleBasedBreakIterator(data, RuleBasedBreakIterator::kDontAdopt, status)
1502 { 1516 {
1503 } 1517 }
1504 1518
1505 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ 1519 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
OLDNEW
« no previous file with comments | « source/i18n/filteredbrk.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698