diff options
author | Michael Stahl <mstahl@redhat.com> | 2016-01-21 18:11:12 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-01-25 15:54:14 +0000 |
commit | 6e193148df69eff428fec23560e9d3ad4f503597 (patch) | |
tree | 0de7eb36b0b70d09ea03e242e648bc881d10f3f8 /starmath | |
parent | cb989a58ec456a340a8a1f26683847f9b2a87caa (diff) |
i18npool: handle non-BMP Unicode in cclass_Unicode::parseText()
The UTF-16 code unit limitation was mangling starmath import.
Change-Id: I087e5c5b7954799fdb73e7ee1a8d3d02669f8831
(cherry picked from commit fefd1221be844a033e409a18e05e8c6e98f6d1a7)
Reviewed-on: https://gerrit.libreoffice.org/21784
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/qa/cppunit/test_nodetotextvisitors.cxx | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx index a539761f43ab..91d7203d1a8d 100644 --- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx +++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx @@ -26,7 +26,6 @@ typedef tools::SvRef<SmDocShell> SmDocShellRef; using namespace ::com::sun::star; -namespace { class Test : public test::BootstrapFixture { @@ -53,6 +52,7 @@ public: void testBinHorInSubSup(); void testUnaryInMixedNumberAsNumerator(); void testMiscEquivalent(); + void testParser(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(SimpleUnaryOp); @@ -72,6 +72,7 @@ public: CPPUNIT_TEST(testBinHorInSubSup); CPPUNIT_TEST(testUnaryInMixedNumberAsNumerator); CPPUNIT_TEST(testMiscEquivalent); + CPPUNIT_TEST(testParser); CPPUNIT_TEST_SUITE_END(); private: @@ -486,13 +487,13 @@ void Test::ParseAndCompare(const char *formula1, const char *formula2, const cha SmNode *pNode1, *pNode2; // parse formula1 - OUString sInput1 = OUString::createFromAscii(formula1); + OUString sInput1 = OUString(formula1, strlen(formula1), RTL_TEXTENCODING_UTF8); pNode1 = SmParser().ParseExpression(sInput1); pNode1->Prepare(xDocShRef->GetFormat(), *xDocShRef); SmNodeToTextVisitor(pNode1, sOutput1); // parse formula2 - OUString sInput2 = OUString::createFromAscii(formula2); + OUString sInput2 = OUString(formula2, strlen(formula2), RTL_TEXTENCODING_UTF8); pNode2 = SmParser().ParseExpression(sInput2); pNode2->Prepare(xDocShRef->GetFormat(), *xDocShRef); SmNodeToTextVisitor(pNode2, sOutput2); @@ -652,10 +653,27 @@ void Test::testMiscEquivalent() // fdo#66081 ParseAndCompare("{x}", "x", "Variable in brace"); ParseAndCompare("{{x+{{y}}}}", "x+y", "Nested braces"); + + // check non-BMP Unicode char + ParseAndCompare("{\xf0\x9d\x91\x8e}", "\xf0\x9d\x91\x8e", "non-BMP variable in brace"); + ParseAndCompare("{ \xf0\x9d\x91\x8e }", "\xf0\x9d\x91\x8e", "non-BMP variable in brace"); } -CPPUNIT_TEST_SUITE_REGISTRATION(Test); +void Test::testParser() +{ + char const* formula = "{ \xf0\x9d\x91\x8e }"; // non-BMP Unicode + char const* expected = "\xf0\x9d\x91\x8e"; + OUString sOutput; + OUString sInput = OUString(formula, strlen(formula), RTL_TEXTENCODING_UTF8); + OUString sExpected = OUString(expected, strlen(expected), RTL_TEXTENCODING_UTF8); + std::unique_ptr<SmNode> pNode(SmParser().ParseExpression(sInput)); + pNode->Prepare(xDocShRef->GetFormat(), *xDocShRef); + SmNodeToTextVisitor(pNode.get(), sOutput); + CPPUNIT_ASSERT_EQUAL(sExpected, sOutput); } +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |