summaryrefslogtreecommitdiff
path: root/starmath/qa
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2018-01-16 18:40:23 +0900
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-01-17 07:45:05 +0100
commit5306ae7ecd8ffa8bb78c95106b46322ae4ca1157 (patch)
tree064751022a381262924163960412ef3ecb77b42a /starmath/qa
parent688b16df55afa1920f007b5bbe52c24f431c4ac2 (diff)
starmath: Make SmParser::ParseExpression() return std::unique_ptr
Change-Id: Ib8b65dced2af3ac7dca3fe9dd02e70f02c865f79 Reviewed-on: https://gerrit.libreoffice.org/47974 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath/qa')
-rw-r--r--starmath/qa/cppunit/test_nodetotextvisitors.cxx33
1 files changed, 11 insertions, 22 deletions
diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index 6791e9d6270c..5399e68ec338 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -431,18 +431,17 @@ void Test::SimpleSpecialChars()
void Test::parseandparseagain(const char *formula, const char *test_name)
{
OUString output1, output2;
- SmNode *pNode1, *pNode2;
// parse 1
OUString input = OUString::createFromAscii(formula);
- pNode1 = SmParser().ParseExpression(input);
+ auto pNode1 = SmParser().ParseExpression(input);
pNode1->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0);
- SmNodeToTextVisitor(pNode1, output1);
+ SmNodeToTextVisitor(pNode1.get(), output1);
// parse 2
- pNode2 = SmParser().ParseExpression(output1);
+ auto pNode2 = SmParser().ParseExpression(output1);
pNode2->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0);
- SmNodeToTextVisitor(pNode2, output2);
+ SmNodeToTextVisitor(pNode2.get(), output2);
// compare
CPPUNIT_ASSERT_EQUAL_MESSAGE(test_name,
@@ -453,21 +452,17 @@ void Test::parseandparseagain(const char *formula, const char *test_name)
std::unique_ptr<MockVisitor> mv(new MockVisitor);
pNode1->Accept(mv.get());
pNode2->Accept(mv.get());
-
- delete pNode1;
- delete pNode2;
}
void Test::ParseAndCheck(const char *formula, const char * expected, const char *test_name)
{
OUString sOutput;
- SmNode *pNode;
// parse
OUString sInput = OUString::createFromAscii(formula);
- pNode = SmParser().ParseExpression(sInput);
+ auto pNode = SmParser().ParseExpression(sInput);
pNode->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0);
- SmNodeToTextVisitor(pNode, sOutput);
+ SmNodeToTextVisitor(pNode.get(), sOutput);
// compare
OUString sExpected = OUString::createFromAscii(expected);
@@ -478,27 +473,24 @@ void Test::ParseAndCheck(const char *formula, const char * expected, const char
// auxiliary test for Accept()
std::unique_ptr<MockVisitor> mv(new MockVisitor);
pNode->Accept(mv.get());
-
- 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(formula1, strlen(formula1), RTL_TEXTENCODING_UTF8);
- pNode1 = SmParser().ParseExpression(sInput1);
+ auto pNode1 = SmParser().ParseExpression(sInput1);
pNode1->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0);
- SmNodeToTextVisitor(pNode1, sOutput1);
+ SmNodeToTextVisitor(pNode1.get(), sOutput1);
// parse formula2
OUString sInput2 = OUString(formula2, strlen(formula2), RTL_TEXTENCODING_UTF8);
- pNode2 = SmParser().ParseExpression(sInput2);
+ auto pNode2 = SmParser().ParseExpression(sInput2);
pNode2->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0);
- SmNodeToTextVisitor(pNode2, sOutput2);
+ SmNodeToTextVisitor(pNode2.get(), sOutput2);
CPPUNIT_ASSERT_EQUAL_MESSAGE(test_name, sOutput1, sOutput2);
@@ -506,9 +498,6 @@ void Test::ParseAndCompare(const char *formula1, const char *formula2, const cha
std::unique_ptr<MockVisitor> mv(new MockVisitor);
pNode1->Accept(mv.get());
pNode2->Accept(mv.get());
-
- delete pNode1;
- delete pNode2;
}
void Test::testBinomInBinHor()
@@ -670,7 +659,7 @@ void Test::testParser()
OUString sOutput;
OUString sInput(u"{ \U0001D44E }"); // non-BMP Unicode
OUString sExpected(u"\U0001D44E");
- std::unique_ptr<SmNode> pNode(SmParser().ParseExpression(sInput));
+ auto pNode = SmParser().ParseExpression(sInput);
pNode->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0);
SmNodeToTextVisitor(pNode.get(), sOutput);
CPPUNIT_ASSERT_EQUAL(sExpected, sOutput);