diff options
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/qa/cppunit/test_node.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
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 <smdll.hxx> #include <node.hxx> #include <parse.hxx> +#include <utility.hxx> #include <memory> @@ -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<double>(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<const SmSpecialNode *>(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); } |