[Libreoffice-commits] core.git: starmath/qa
Takeshi Abe
tabe at fixedpoint.jp
Sun Jul 24 13:00:15 UTC 2016
starmath/qa/cppunit/test_node.cxx | 49 ++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
New commits:
commit 90517f4071c0a5950f88227c5ec345f4aa6ca0cd
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Sun Jul 24 05:52:57 2016 +0900
starmath: Add unit test for tdf#52225
Change-Id: Id0e9cb3f2fb939bedc2f8e7a56d40a0f82c1e9ca
Reviewed-on: https://gerrit.libreoffice.org/27469
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Takeshi Abe <tabe at fixedpoint.jp>
diff --git a/starmath/qa/cppunit/test_node.cxx b/starmath/qa/cppunit/test_node.cxx
index 5f2dca8..b07f26c 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);
}
More information about the Libreoffice-commits
mailing list