summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-07-13 12:49:28 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-07-13 12:49:28 +0100
commit52280c29880c2d6bc533692d3f0cdff37f35790d (patch)
tree527192a33db8a71af402e69d38d19f6b0bbbd0d4
parent0d2afe08450ad041afa21adf48d6c6d90e8cc4e0 (diff)
Related: fdo#49629 add test case for #i11993#
Change-Id: I4466b57514352620fd26072544ec6e50bf08708c
-rw-r--r--i18npool/qa/cppunit/test_breakiterator.cxx43
1 files changed, 43 insertions, 0 deletions
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx
index 57c70e403f07..a65d0b6955fe 100644
--- a/i18npool/qa/cppunit/test_breakiterator.cxx
+++ b/i18npool/qa/cppunit/test_breakiterator.cxx
@@ -54,6 +54,7 @@ public:
virtual void tearDown();
void testLineBreaking();
+ void testWordBoundaries();
void testGraphemeIteration();
void testWeak();
void testAsian();
@@ -67,6 +68,7 @@ public:
CPPUNIT_TEST_SUITE(TestBreakIterator);
CPPUNIT_TEST(testLineBreaking);
+ CPPUNIT_TEST(testWordBoundaries);
CPPUNIT_TEST(testGraphemeIteration);
CPPUNIT_TEST(testWeak);
CPPUNIT_TEST(testAsian);
@@ -125,6 +127,47 @@ void TestBreakIterator::testLineBreaking()
}
}
+//See https://bugs.freedesktop.org/show_bug.cgi?id=49629
+void TestBreakIterator::testWordBoundaries()
+{
+ lang::Locale aLocale;
+ aLocale.Language = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en"));
+ aLocale.Country = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("US"));
+
+ i18n::Boundary aBounds;
+
+ //See https://issues.apache.org/ooo/show_bug.cgi?id=11993
+ {
+ ::rtl::OUString aTest("abcd ef ghi??? KLM");
+
+ CPPUNIT_ASSERT(!m_xBreak->isBeginWord(aTest, 4, aLocale, i18n::WordType::DICTIONARY_WORD));
+ CPPUNIT_ASSERT(m_xBreak->isEndWord(aTest, 4, aLocale, i18n::WordType::DICTIONARY_WORD));
+ aBounds = m_xBreak->getWordBoundary(aTest, 4, aLocale, i18n::WordType::DICTIONARY_WORD, true);
+ CPPUNIT_ASSERT(aBounds.startPos == 0 && aBounds.endPos == 4);
+
+ CPPUNIT_ASSERT(!m_xBreak->isBeginWord(aTest, 8, aLocale, i18n::WordType::DICTIONARY_WORD));
+ CPPUNIT_ASSERT(!m_xBreak->isEndWord(aTest, 8, aLocale, i18n::WordType::DICTIONARY_WORD));
+
+ //next word
+ aBounds = m_xBreak->getWordBoundary(aTest, 8, aLocale, i18n::WordType::DICTIONARY_WORD, true);
+ CPPUNIT_ASSERT(aBounds.startPos == 9 && aBounds.endPos == 12);
+
+ //previous word
+ aBounds = m_xBreak->getWordBoundary(aTest, 8, aLocale, i18n::WordType::DICTIONARY_WORD, false);
+ CPPUNIT_ASSERT(aBounds.startPos == 5 && aBounds.endPos == 7);
+
+ CPPUNIT_ASSERT(!m_xBreak->isBeginWord(aTest, 12, aLocale, i18n::WordType::DICTIONARY_WORD));
+ CPPUNIT_ASSERT(m_xBreak->isEndWord(aTest, 12, aLocale, i18n::WordType::DICTIONARY_WORD));
+ aBounds = m_xBreak->getWordBoundary(aTest, 12, aLocale, i18n::WordType::DICTIONARY_WORD, true);
+ CPPUNIT_ASSERT(aBounds.startPos == 9 && aBounds.endPos == 12);
+
+ CPPUNIT_ASSERT(m_xBreak->isBeginWord(aTest, 16, aLocale, i18n::WordType::DICTIONARY_WORD));
+ CPPUNIT_ASSERT(!m_xBreak->isEndWord(aTest, 16, aLocale, i18n::WordType::DICTIONARY_WORD));
+ aBounds = m_xBreak->getWordBoundary(aTest, 16, aLocale, i18n::WordType::DICTIONARY_WORD, true);
+ CPPUNIT_ASSERT(aBounds.startPos == 16 && aBounds.endPos == 19);
+ }
+}
+
//See http://qa.openoffice.org/issues/show_bug.cgi?id=111152
//See https://bugs.freedesktop.org/show_bug.cgi?id=40292
void TestBreakIterator::testGraphemeIteration()