From 20c24114143d6d38774b56a142fd4ae05094308e Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 13 May 2012 22:41:30 +0100 Subject: Resolves: fdo#49849 implement Unicode 6.1 hebrew line breaking rules i.e. sync with svn diff -c 31071 http://source.icu-project.org/repos/icu/icu/trunk/source/data/brkitr/line.txt Change-Id: I I I41b3d02f1a0da3b83a9684f29d466660d96254c6 --- i18npool/qa/cppunit/test_breakiterator.cxx | 89 +++++++++++++++++++----------- 1 file changed, 58 insertions(+), 31 deletions(-) (limited to 'i18npool/qa/cppunit') diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx index 14051d4ee358..ffd590c0c05a 100644 --- a/i18npool/qa/cppunit/test_breakiterator.cxx +++ b/i18npool/qa/cppunit/test_breakiterator.cxx @@ -42,6 +42,7 @@ #include #include +#include #include @@ -58,6 +59,9 @@ public: void testWeak(); void testAsian(); void testThai(); +#if TODO + void testNorthernThai(); +#endif CPPUNIT_TEST_SUITE(TestBreakIterator); CPPUNIT_TEST(testLineBreaking); @@ -65,33 +69,54 @@ public: CPPUNIT_TEST(testWeak); CPPUNIT_TEST(testAsian); CPPUNIT_TEST(testThai); +#if TODO + CPPUNIT_TEST(testNorthernThai); +#endif CPPUNIT_TEST_SUITE_END(); private: uno::Reference m_xBreak; }; -//See https://bugs.freedesktop.org/show_bug.cgi?id=31271 void TestBreakIterator::testLineBreaking() { - ::rtl::OUString aTest(RTL_CONSTASCII_USTRINGPARAM("(some text here)")); - i18n::LineBreakHyphenationOptions aHyphOptions; i18n::LineBreakUserOptions aUserOptions; lang::Locale aLocale; - aLocale.Language = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en")); - aLocale.Country = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("US")); - + //See https://bugs.freedesktop.org/show_bug.cgi?id=31271 { - //Here we want the line break to leave text here) on the next line - i18n::LineBreakResults aResult = m_xBreak->getLineBreak(aTest, strlen("(some tex"), aLocale, 0, aHyphOptions, aUserOptions); - CPPUNIT_ASSERT_MESSAGE("Expected a break at the the start of the word", aResult.breakIndex == 6); + ::rtl::OUString aTest(RTL_CONSTASCII_USTRINGPARAM("(some text here)")); + + aLocale.Language = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en")); + aLocale.Country = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("US")); + + { + //Here we want the line break to leave text here) on the next line + i18n::LineBreakResults aResult = m_xBreak->getLineBreak(aTest, strlen("(some tex"), aLocale, 0, aHyphOptions, aUserOptions); + CPPUNIT_ASSERT_MESSAGE("Expected a break at the the start of the word", aResult.breakIndex == 6); + } + + { + //Here we want the line break to leave "here)" on the next line + i18n::LineBreakResults aResult = m_xBreak->getLineBreak(aTest, strlen("(some text here"), aLocale, 0, aHyphOptions, aUserOptions); + CPPUNIT_ASSERT_MESSAGE("Expected a break at the the start of the word", aResult.breakIndex == 11); + } } + //See https://bugs.freedesktop.org/show_bug.cgi?id=49849 { - //Here we want the line break to leave "here)" on the next line - i18n::LineBreakResults aResult = m_xBreak->getLineBreak(aTest, strlen("(some text here"), aLocale, 0, aHyphOptions, aUserOptions); - CPPUNIT_ASSERT_MESSAGE("Expected a break at the the start of the word", aResult.breakIndex == 11); + const sal_Unicode HEBREW1[] = { 0x05DE, 0x05D9, 0x05DC, 0x05D9, 0x5DD }; + ::rtl::OUString aWord(HEBREW1, SAL_N_ELEMENTS(HEBREW1)); + ::rtl::OUString aTest(rtl::OUStringBuffer(aWord).append(' ').append(aWord).makeStringAndClear()); + + aLocale.Language = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("he")); + aLocale.Country = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IL")); + + { + //Here we want the line break to happen at the whitespace + i18n::LineBreakResults aResult = m_xBreak->getLineBreak(aTest, aTest.getLength()-1, aLocale, 0, aHyphOptions, aUserOptions); + CPPUNIT_ASSERT_MESSAGE("Expected a break at the the start of the word", aResult.breakIndex == aWord.getLength()+1); + } } } @@ -295,27 +320,29 @@ void TestBreakIterator::testThai() aLocale.Language = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("th")); aLocale.Country = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TH")); - i18n::Boundary aBounds; - { - const sal_Unicode THAI1[] = { 0x0E01, 0x0E38, 0x0E2B, 0x0E25, 0x0E32, 0x0E1A }; - ::rtl::OUString aTest(THAI1, SAL_N_ELEMENTS(THAI1)); - aBounds = m_xBreak->getWordBoundary(aTest, 0, aLocale, - i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT_MESSAGE("Should skip full word", - aBounds.startPos == 0 && aBounds.endPos == aTest.getLength()); - } + const sal_Unicode THAI1[] = { 0x0E01, 0x0E38, 0x0E2B, 0x0E25, 0x0E32, 0x0E1A }; + ::rtl::OUString aTest(THAI1, SAL_N_ELEMENTS(THAI1)); + i18n::Boundary aBounds = m_xBreak->getWordBoundary(aTest, 0, aLocale, + i18n::WordType::DICTIONARY_WORD, true); + CPPUNIT_ASSERT_MESSAGE("Should skip full word", + aBounds.startPos == 0 && aBounds.endPos == aTest.getLength()); +} -#ifdef TODO - { - const sal_Unicode NORTHERN_THAI1[] = { 0x0E01, 0x0E38, 0x0E4A, 0x0E2B, 0x0E25, 0x0E32, 0x0E1A }; - ::rtl::OUString aTest(NORTHERN_THAI1, SAL_N_ELEMENTS(NORTHERN_THAI1)); - aBounds = m_xBreak->getWordBoundary(aTest, 0, aLocale, - i18n::WordType::DICTIONARY_WORD, true); - CPPUNIT_ASSERT_MESSAGE("Should skip full word", - aBounds.startPos == 0 && aBounds.endPos == aTest.getLength()); - } -#endif +#if TODO +void TestBreakIterator::testNorthernThai() +{ + lang::Locale aLocale; + aLocale.Language = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nod")); + aLocale.Country = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TH")); + + const sal_Unicode NORTHERN_THAI1[] = { 0x0E01, 0x0E38, 0x0E4A, 0x0E2B, 0x0E25, 0x0E32, 0x0E1A }; + ::rtl::OUString aTest(NORTHERN_THAI1, SAL_N_ELEMENTS(NORTHERN_THAI1)); + i18n::Boundary aBounds = m_xBreak->getWordBoundary(aTest, 0, aLocale, + i18n::WordType::DICTIONARY_WORD, true); + CPPUNIT_ASSERT_MESSAGE("Should skip full word", + aBounds.startPos == 0 && aBounds.endPos == aTest.getLength()); } +#endif void TestBreakIterator::setUp() { -- cgit v1.2.3