diff options
author | Frédéric Wang <fred.wang@free.fr> | 2013-07-05 21:28:47 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2013-07-09 08:07:46 +0000 |
commit | 48d696e2049e771ebc797b7a7694e02de89b6020 (patch) | |
tree | cdde47b77d0fe3b63b3a1ff8681a9ff1bdbc3bfc /starmath | |
parent | 7da06efd74be6500895bab6e5e8ed485914ff45e (diff) |
Tests for fdo#55853, i#11752, fdo#66081
Change-Id: Ifb1fc23c416f47c6618e7ef22a53b1744ff0e2bc
Reviewed-on: https://gerrit.libreoffice.org/4748
Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
Tested-by: Khaled Hosny <khaledhosny@eglug.org>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/qa/cppunit/test_nodetotextvisitors.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx index 6ce2e5d62ae5..4409d97e8302 100644 --- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx +++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx @@ -75,6 +75,7 @@ public: void testBinVerInUnary(); void testBinHorInSubSup(); void testUnaryInMixedNumberAsNumerator(); + void testMiscEquivalent(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(SimpleUnaryOp); @@ -93,6 +94,7 @@ public: CPPUNIT_TEST(testBinVerInUnary); CPPUNIT_TEST(testBinHorInSubSup); CPPUNIT_TEST(testUnaryInMixedNumberAsNumerator); + CPPUNIT_TEST(testMiscEquivalent); CPPUNIT_TEST_SUITE_END(); private: @@ -100,6 +102,7 @@ private: SmDocShellRef xDocShRef; void parseandparseagain(const char *input, const char *test_name); void ParseAndCheck(const char *input, const char *expected, const char *test_name); + void ParseAndCompare(const char *formula1, const char *formula2, const char *test_name); }; void Test::setUp() @@ -490,6 +493,30 @@ void Test::ParseAndCheck(const char *formula, const char * expected, const char delete pNode; } +// Parse two formula commands and verify that they give the same output +void Test::ParseAndCompare(const char *formula1, const char *formula2, const char *test_name) +{ + OUString sOutput1, sOutput2; + SmNode *pNode1, *pNode2; + + // parse formula1 + OUString sInput1 = OUString::createFromAscii(formula1); + pNode1 = SmParser().ParseExpression(sInput1); + pNode1->Prepare(xDocShRef->GetFormat(), *xDocShRef); + SmNodeToTextVisitor(pNode1, sOutput1); + + // parse formula2 + OUString sInput2 = OUString::createFromAscii(formula2); + pNode2 = SmParser().ParseExpression(sInput2); + pNode2->Prepare(xDocShRef->GetFormat(), *xDocShRef); + SmNodeToTextVisitor(pNode2, sOutput2); + + CPPUNIT_ASSERT_EQUAL_MESSAGE(test_name, sOutput1, sOutput2); + + delete pNode1; + delete pNode2; +} + void Test::testBinomInBinHor() { String sInput, sExpected; @@ -627,6 +654,21 @@ void Test::testUnaryInMixedNumberAsNumerator() delete pTree; } +void Test::testMiscEquivalent() +{ + // fdo#55853 + ParseAndCompare("2x", "2 x", "Number times variable"); + ParseAndCompare("3x^2", "3 x^2", "Number times power"); + + // i#11752 and fdo#55853 + ParseAndCompare("x_2n", "x_{2 n}", "Number times variable in subscript"); + ParseAndCompare("x^2n", "x^{2 n}", "Number times variable in supscript"); + + // fdo#66081 + ParseAndCompare("{x}", "x", "Variable in brace"); + ParseAndCompare("{{x+{{y}}}}", "x+y", "Nested braces"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } |