diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-11-03 11:00:38 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-11-03 12:18:17 +0000 |
commit | 12db5315fca413ae66e88c4cd8212ee3b01667b7 (patch) | |
tree | 2e8abe3a62ee41a39b3a7aeaf261923f02bc41f6 /i18npool/qa/cppunit | |
parent | 56d5a48099165dabb72eb3a2655c2eb503684f1c (diff) |
Follow UAX-29 and present user-perceived character counts
Not a count of code-units, nor a count of code-points, but try and follow
http://unicode.org/reports/tr29/ and present the grapheme count.
Add a few representative tests to try and avoid gotchas.
Diffstat (limited to 'i18npool/qa/cppunit')
-rw-r--r-- | i18npool/qa/cppunit/test_breakiterator.cxx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx index ab5936aa0934..dfe342490c3d 100644 --- a/i18npool/qa/cppunit/test_breakiterator.cxx +++ b/i18npool/qa/cppunit/test_breakiterator.cxx @@ -151,6 +151,24 @@ void TestBreakIterator::testGraphemeIteration() i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); CPPUNIT_ASSERT_MESSAGE("Should skip full grapheme", nPos == 0); } + + { + const sal_Unicode ALEF_QAMATS [] = { 0x05D0, 0x05B8 }; + ::rtl::OUString aText(ALEF_QAMATS, SAL_N_ELEMENTS(ALEF_QAMATS)); + + sal_Int32 nGraphemeCount = 0; + + sal_Int32 nCurPos = 0; + while (nCurPos < aText.getLength()) + { + sal_Int32 nCount2 = 1; + nCurPos = m_xBreak->nextCharacters(aText, nCurPos, lang::Locale(), + i18n::CharacterIteratorMode::SKIPCELL, nCount2, nCount2); + ++nGraphemeCount; + } + + CPPUNIT_ASSERT_MESSAGE("Should be considered 1 grapheme", nGraphemeCount == 1); + } } //A test to ensure that certain ranges and codepoints that are categorized as |