diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2018-01-18 18:20:12 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2018-01-22 06:26:00 +0100 |
commit | f3d1b2e58c39618d99bf017702ef19f373464b34 (patch) | |
tree | eee2d5e21b1bfe7fde0732e22f47ce02501b7b97 /starmath/qa/cppunit | |
parent | f1d1eb2c647af7b751b024faef09e01d849aacbb (diff) |
starmath: Make SmParser::Parse() return std::unique_ptr
Change-Id: I6c8811f71ab40398043cdcfa3334eee4381b4c7e
Reviewed-on: https://gerrit.libreoffice.org/48098
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath/qa/cppunit')
-rw-r--r-- | starmath/qa/cppunit/test_cursor.cxx | 8 | ||||
-rw-r--r-- | starmath/qa/cppunit/test_node.cxx | 8 | ||||
-rw-r--r-- | starmath/qa/cppunit/test_nodetotextvisitors.cxx | 26 | ||||
-rw-r--r-- | starmath/qa/cppunit/test_parse.cxx | 4 |
4 files changed, 18 insertions, 28 deletions
diff --git a/starmath/qa/cppunit/test_cursor.cxx b/starmath/qa/cppunit/test_cursor.cxx index 702777a614f8..403994707d27 100644 --- a/starmath/qa/cppunit/test_cursor.cxx +++ b/starmath/qa/cppunit/test_cursor.cxx @@ -68,7 +68,7 @@ void Test::tearDown() void Test::testCopyPaste() { OUString const sInput("a * b + c"); - std::unique_ptr<SmNode> xTree(SmParser().Parse(sInput)); + auto xTree = SmParser().Parse(sInput); xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(xTree.get(), xDocShRef.get()); @@ -91,7 +91,7 @@ void Test::testCopyPaste() void Test::testCopySelectPaste() { OUString const sInput("a * b + c"); - std::unique_ptr<SmNode> xTree(SmParser().Parse(sInput)); + auto xTree = SmParser().Parse(sInput); xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(xTree.get(), xDocShRef.get()); @@ -118,7 +118,7 @@ void Test::testCopySelectPaste() void Test::testCutPaste() { OUString const sInput("a * b + c"); - std::unique_ptr<SmNode> xTree(SmParser().Parse(sInput)); + auto xTree = SmParser().Parse(sInput); xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(xTree.get(), xDocShRef.get()); @@ -141,7 +141,7 @@ void Test::testCutPaste() void Test::testCutSelectPaste() { OUString const sInput("a * b + c"); - std::unique_ptr<SmNode> xTree(SmParser().Parse(sInput)); + auto xTree = SmParser().Parse(sInput); xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(xTree.get(), xDocShRef.get()); diff --git a/starmath/qa/cppunit/test_node.cxx b/starmath/qa/cppunit/test_node.cxx index 2a35bdffbe4c..ebf0682f531e 100644 --- a/starmath/qa/cppunit/test_node.cxx +++ b/starmath/qa/cppunit/test_node.cxx @@ -64,10 +64,10 @@ void NodeTest::testTdf47813() { SmParser aParser; #define MATRIX "matrix {-2#33##4#-5##6,0#7}" - std::unique_ptr<SmTableNode> pNodeA(aParser.Parse(MATRIX)); - std::unique_ptr<SmTableNode> pNodeC(aParser.Parse("alignc " MATRIX)); - std::unique_ptr<SmTableNode> pNodeL(aParser.Parse("alignl " MATRIX)); - std::unique_ptr<SmTableNode> pNodeR(aParser.Parse("alignr " MATRIX)); + auto pNodeA = aParser.Parse(MATRIX); + auto pNodeC = aParser.Parse("alignc " MATRIX); + auto pNodeL = aParser.Parse("alignl " MATRIX); + auto pNodeR = aParser.Parse("alignr " MATRIX); #undef MATRIX ScopedVclPtrInstance<VirtualDevice> pOutputDevice; SmFormat aFmt; diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx index 5399e68ec338..5c92b712334b 100644 --- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx +++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx @@ -503,14 +503,13 @@ void Test::ParseAndCompare(const char *formula1, const char *formula2, const cha void Test::testBinomInBinHor() { OUString sInput, sExpected; - SmNode* pTree; // set up a binom (table) node sInput += "binom a b + c"; - pTree = SmParser().Parse(sInput); + auto pTree = SmParser().Parse(sInput); pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); - SmCursor aCursor(pTree, xDocShRef.get()); + SmCursor aCursor(pTree.get(), xDocShRef.get()); ScopedVclPtrInstance< VirtualDevice > pOutputDevice; // move forward (more than) enough places to be at the end @@ -524,21 +523,18 @@ void Test::testBinomInBinHor() sExpected += " { { binom a b + c } + d } "; CPPUNIT_ASSERT_EQUAL_MESSAGE("Binom Node in BinHor Node", sExpected, xDocShRef->GetText()); - - delete pTree; } void Test::testBinVerInUnary() { OUString sInput, sExpected; - SmNode* pTree; // set up a unary operator with operand sInput += "- 1"; - pTree = SmParser().Parse(sInput); + auto pTree = SmParser().Parse(sInput); pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); - SmCursor aCursor(pTree, xDocShRef.get()); + SmCursor aCursor(pTree.get(), xDocShRef.get()); ScopedVclPtrInstance< VirtualDevice > pOutputDevice; // move forward (more than) enough places to be at the end @@ -555,17 +551,15 @@ void Test::testBinVerInUnary() sExpected += " - { 1 over 2 } "; CPPUNIT_ASSERT_EQUAL_MESSAGE("Binary Vertical in Unary Operator", sExpected, xDocShRef->GetText()); - - delete pTree; } void Test::testBinHorInSubSup() { // set up a blank formula - SmNode* pTree = SmParser().Parse(OUString()); + auto pTree = SmParser().Parse(OUString()); pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); - SmCursor aCursor(pTree, xDocShRef.get()); + SmCursor aCursor(pTree.get(), xDocShRef.get()); ScopedVclPtrInstance< VirtualDevice > pOutputDevice; // Insert an RSup expression with a BinHor for the exponent @@ -582,18 +576,16 @@ void Test::testBinHorInSubSup() OUString sExpected = " { a ^ { b + c } + d } "; CPPUNIT_ASSERT_EQUAL_MESSAGE("BinHor in SubSup", sExpected, xDocShRef->GetText()); - - delete pTree; } void Test::testUnaryInMixedNumberAsNumerator() { // set up a unary operator OUString sInput = "- 1"; - SmNode* pTree = SmParser().Parse(sInput); + auto pTree = SmParser().Parse(sInput); pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); - SmCursor aCursor(pTree, xDocShRef.get()); + SmCursor aCursor(pTree.get(), xDocShRef.get()); ScopedVclPtrInstance< VirtualDevice > pOutputDevice; // move forward (more than) enough places to be at the end @@ -625,8 +617,6 @@ void Test::testUnaryInMixedNumberAsNumerator() OUString sExpected = " { 2 { - 1 over 2 } + 4 } "; CPPUNIT_ASSERT_EQUAL_MESSAGE("Unary in mixed number as Numerator", sExpected, xDocShRef->GetText()); - - delete pTree; } void Test::testMiscEquivalent() diff --git a/starmath/qa/cppunit/test_parse.cxx b/starmath/qa/cppunit/test_parse.cxx index c99a80568839..ff5a12e72425 100644 --- a/starmath/qa/cppunit/test_parse.cxx +++ b/starmath/qa/cppunit/test_parse.cxx @@ -65,7 +65,7 @@ void ParseTest::tearDown() */ void ParseTest::testMinus() { - std::unique_ptr<SmTableNode> pNode(SmParser().Parse("-1.2")); + auto pNode = SmParser().Parse("-1.2"); CPPUNIT_ASSERT_EQUAL(size_t(1), pNode->GetNumSubNodes()); const SmNode *pNode0 = pNode->GetSubNode(0); CPPUNIT_ASSERT(pNode0); @@ -98,7 +98,7 @@ void ParseTest::testMinus() */ void ParseTest::testNospace() { - std::unique_ptr<SmTableNode> pNode(SmParser().Parse("nospace{ nitalic d {F(x) G(x)} }")); + auto pNode = SmParser().Parse("nospace{ nitalic d {F(x) G(x)} }"); CPPUNIT_ASSERT_EQUAL(size_t(1), pNode->GetNumSubNodes()); const SmNode *pNode0 = pNode->GetSubNode(0); CPPUNIT_ASSERT(pNode0); |