summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2016-07-24 05:52:57 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2016-07-24 12:59:46 +0000
commit90517f4071c0a5950f88227c5ec345f4aa6ca0cd (patch)
tree7487d42ee345f22dd76864b6bd61d83400fb4a4d /starmath
parentb49005115076771da2669d120e72606bc2b0f532 (diff)
starmath: Add unit test for tdf#52225
Change-Id: Id0e9cb3f2fb939bedc2f8e7a56d40a0f82c1e9ca Reviewed-on: https://gerrit.libreoffice.org/27469 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/qa/cppunit/test_node.cxx49
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);
}