From 90517f4071c0a5950f88227c5ec345f4aa6ca0cd Mon Sep 17 00:00:00 2001 From: Takeshi Abe Date: Sun, 24 Jul 2016 05:52:57 +0900 Subject: starmath: Add unit test for tdf#52225 Change-Id: Id0e9cb3f2fb939bedc2f8e7a56d40a0f82c1e9ca Reviewed-on: https://gerrit.libreoffice.org/27469 Tested-by: Jenkins Reviewed-by: Takeshi Abe --- starmath/qa/cppunit/test_node.cxx | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'starmath/qa/cppunit') diff --git a/starmath/qa/cppunit/test_node.cxx b/starmath/qa/cppunit/test_node.cxx index 5f2dca8d3122..b07f26ca039a 100644 --- a/starmath/qa/cppunit/test_node.cxx +++ b/starmath/qa/cppunit/test_node.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -33,9 +34,11 @@ public: private: void testTdf47813(); + void testTdf52225(); CPPUNIT_TEST_SUITE(NodeTest); CPPUNIT_TEST(testTdf47813); + CPPUNIT_TEST(testTdf52225); CPPUNIT_TEST_SUITE_END(); SmDocShellRef mxDocShell; @@ -81,6 +84,52 @@ void NodeTest::testTdf47813() CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, nWidthR/static_cast(nWidthA), 0.01); } +void NodeTest::testTdf52225() +{ +#define CHECK_GREEK_SYMBOL(text, code, bItalic) do { \ + mxDocShell->SetText(text); \ + const SmTableNode *pTree= mxDocShell->GetFormulaTree(); \ + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pTree->GetNumSubNodes()); \ + const SmNode *pLine = pTree->GetSubNode(0); \ + CPPUNIT_ASSERT(pLine); \ + CPPUNIT_ASSERT_EQUAL(NLINE, pLine->GetType()); \ + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pLine->GetNumSubNodes()); \ + const SmNode *pNode = pLine->GetSubNode(0); \ + CPPUNIT_ASSERT(pNode); \ + CPPUNIT_ASSERT_EQUAL(NSPECIAL, pNode->GetType()); \ + const SmSpecialNode *pSn = static_cast(pNode); \ + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pSn->GetText().getLength()); \ + CPPUNIT_ASSERT_EQUAL(sal_Unicode(code), pSn->GetText()[0]); \ + CPPUNIT_ASSERT_EQUAL(OUString(text), pSn->GetToken().aText); \ + CPPUNIT_ASSERT_EQUAL(bItalic, IsItalic(pSn->GetFont())); \ + } while (false) + + SmFormat aFormat = mxDocShell->GetFormat(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aFormat.GetGreekCharStyle()); // default format + CHECK_GREEK_SYMBOL("%ALPHA", 0x0391, false); + CHECK_GREEK_SYMBOL("%iALPHA", 0x0391, true); + CHECK_GREEK_SYMBOL("%alpha", 0x03b1, false); + CHECK_GREEK_SYMBOL("%ialpha", 0x03b1, true); + + // mode 1 + aFormat.SetGreekCharStyle(1); + mxDocShell->SetFormat(aFormat); + CHECK_GREEK_SYMBOL("%BETA", 0x0392, true); + CHECK_GREEK_SYMBOL("%iBETA", 0x0392, true); + CHECK_GREEK_SYMBOL("%beta", 0x03b2, true); + CHECK_GREEK_SYMBOL("%ibeta", 0x03b2, true); + + // mode 2 + aFormat.SetGreekCharStyle(2); + mxDocShell->SetFormat(aFormat); + CHECK_GREEK_SYMBOL("%GAMMA", 0x0393, false); + CHECK_GREEK_SYMBOL("%iGAMMA", 0x0393, true); + CHECK_GREEK_SYMBOL("%gamma", 0x03b3, true); + CHECK_GREEK_SYMBOL("%igamma", 0x03b3, true); + +#undef CHECK_GREEK_SYMBOL +} + CPPUNIT_TEST_SUITE_REGISTRATION(NodeTest); } -- cgit