ICU-11325 fix operator==. Also, re-enable French.

X-SVN-Rev: 36672
This commit is contained in:
Steven R. Loomis 2014-10-11 00:22:06 +00:00
parent a9d937e314
commit 547757ebe9
2 changed files with 26 additions and 12 deletions

View file

@ -147,7 +147,7 @@ public:
}
virtual BreakIterator* clone(void) const { return new SimpleFilteredSentenceBreakIterator(*this); }
virtual UClassID getDynamicClassID(void) const { return NULL; }
virtual UBool operator==(const BreakIterator& o) const { if(*this==o) return true; return false; }
virtual UBool operator==(const BreakIterator& o) const { if(this==&o) return true; return false; }
/* -- text modifying -- */
virtual void setText(UText *text, UErrorCode &status) { fDelegate->setText(text,status); }

View file

@ -1226,6 +1226,7 @@ void RBBIAPITest::TestFilteredBreakIteratorBuilder() {
LocalPointer<FilteredBreakIteratorBuilder> builder;
LocalPointer<BreakIterator> baseBI;
LocalPointer<BreakIterator> filteredBI;
LocalPointer<BreakIterator> frenchBI;
const UnicodeString text("In the meantime Mr. Weston arrived with his small ship, which he had now recovered. Capt. Gorges, who informed the Sgt. here that one purpose of his going east was to meet with Mr. Weston, took this opportunity to call him to account for some abuses he had to lay to his charge."); // (William Bradford, public domain. http://catalog.hathitrust.org/Record/008651224 ) - edited.
const UnicodeString ABBR_MR("Mr.");
@ -1240,11 +1241,11 @@ void RBBIAPITest::TestFilteredBreakIteratorBuilder() {
baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish(), status));
TEST_ASSERT_SUCCESS(status);
logln("Building new BI\n");
logln("Building new BI\n");
filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
TEST_ASSERT_SUCCESS(status);
if (U_SUCCESS(status)) {
if (U_SUCCESS(status)) {
logln("Testing:");
filteredBI->setText(text);
TEST_ASSERT(20 == filteredBI->next()); // Mr.
@ -1374,7 +1375,6 @@ void RBBIAPITest::TestFilteredBreakIteratorBuilder() {
}
}
#if 0
// reenable once french is in
{
logln("Constructing French builder");
@ -1386,19 +1386,33 @@ void RBBIAPITest::TestFilteredBreakIteratorBuilder() {
TEST_ASSERT_SUCCESS(status);
logln("Building new BI\n");
filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
frenchBI.adoptInstead(builder->build(baseBI.orphan(), status));
TEST_ASSERT_SUCCESS(status);
if(filteredBI.isValid()) {
if(frenchBI.isValid()) {
logln("Testing:");
filteredBI->setText(text);
TEST_ASSERT(20 == filteredBI->next());
TEST_ASSERT(84 == filteredBI->next());
UnicodeString frText("C'est MM. Duval.");
frenchBI->setText(frText);
TEST_ASSERT(16 == frenchBI->next());
TEST_ASSERT(BreakIterator::DONE == frenchBI->next());
frenchBI->first();
prtbrks(frenchBI.getAlias(), frText, *this);
logln("Testing against English:");
filteredBI->setText(frText);
TEST_ASSERT(10 == filteredBI->next()); // wrong for french, but filterBI is english.
TEST_ASSERT(16 == filteredBI->next());
TEST_ASSERT(BreakIterator::DONE == filteredBI->next());
filteredBI->first();
prtbrks(filteredBI.getAlias(), text, *this);
}
prtbrks(filteredBI.getAlias(), frText, *this);
// Verify ==
TEST_ASSERT_TRUE(*frenchBI == *frenchBI);
TEST_ASSERT_TRUE(*filteredBI != *frenchBI);
TEST_ASSERT_TRUE(*frenchBI != *filteredBI);
} else {
dataerrln("French BI: not valid.");
}
}
#endif
#else
logln("Skipped- not: !UCONFIG_NO_BREAK_ITERATION && U_HAVE_STD_STRING && !UCONFIG_NO_FILTERED_BREAK_ITERATION");