diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-03-15 09:15:50 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-03-15 09:20:30 +0000 |
commit | d6899aef840b9855ef5a967749af81b4cf612319 (patch) | |
tree | 03b8712b53d3efcd1ca302db7dd7bfcc8e66695a /i18npool/qa | |
parent | 7e369e66463750564a9b45700db82ca44c10a561 (diff) |
add regression test for weak chars
Diffstat (limited to 'i18npool/qa')
-rw-r--r-- | i18npool/qa/cppunit/test_breakiterator.cxx | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx index 3f52cdbdad4f..0f42fe7b2164 100644 --- a/i18npool/qa/cppunit/test_breakiterator.cxx +++ b/i18npool/qa/cppunit/test_breakiterator.cxx @@ -37,6 +37,9 @@ #include <cppuhelper/basemutex.hxx> #include <com/sun/star/i18n/XBreakIterator.hpp> #include <com/sun/star/i18n/CharacterIteratorMode.hpp> +#include <com/sun/star/i18n/ScriptType.hdl> + +#include <rtl/strbuf.hxx> #include <string.h> @@ -53,10 +56,12 @@ public: void testLineBreaking(); void testGraphemeIteration(); + void testWeak(); CPPUNIT_TEST_SUITE(TestBreakIterator); CPPUNIT_TEST(testLineBreaking); CPPUNIT_TEST(testGraphemeIteration); + CPPUNIT_TEST(testWeak); CPPUNIT_TEST_SUITE_END(); private: @@ -141,6 +146,44 @@ void TestBreakIterator::testGraphemeIteration() } } +//A test to ensure that certain ranges and codepoints that are categorized as +//weak remain as weak, so that existing docs that depend on this don't silently +//change font for those weak chars +void TestBreakIterator::testWeak() +{ + lang::Locale aLocale; + aLocale.Language = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en")); + aLocale.Country = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("US")); + + { + sal_Unicode WEAKS[] = + { + 0x0001, 0x0002, + 0x0020, 0x00A0, + 0x2200, 0x22FF, //Mathematical Operators + 0x27C0, 0x27EF, //Miscellaneous Mathematical Symbols-A + 0x2980, 0x29FF, //Miscellaneous Mathematical Symbols-B + 0x2A00, 0x2AFF, //Supplemental Mathematical Operators + 0x2100, 0x214F, //Letterlike Symbols + 0x2308, 0x230B, //Miscellaneous technical + 0x25A0, 0x25FF, //Geometric Shapes + 0x2B30, 0x2B4C //Miscellaneous Symbols and Arrows + }; + ::rtl::OUString aWeaks(WEAKS, SAL_N_ELEMENTS(WEAKS)); + + for (sal_Int32 i = 0; i < aWeaks.getLength(); ++i) + { + sal_Int16 nScript = m_xBreak->getScriptType(aWeaks, i); + rtl::OStringBuffer aMsg; + aMsg.append(RTL_CONSTASCII_STRINGPARAM("Char 0x")); + aMsg.append(static_cast<sal_Int32>(aWeaks.getStr()[i]), 16); + aMsg.append(RTL_CONSTASCII_STRINGPARAM(" should have been weak")); + CPPUNIT_ASSERT_MESSAGE(aMsg.getStr(), + nScript == i18n::ScriptType::WEAK); + } + } +} + TestBreakIterator::TestBreakIterator() { m_xContext = cppu::defaultBootstrap_InitialComponentContext(); |