diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2017-03-25 17:52:46 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2017-04-04 01:24:31 +0000 |
commit | 1a1d1a86e9129ec3885610b641179b30f9bf5e79 (patch) | |
tree | 850c593a0777617d4f744c202a3a9a087b82c0fc /starmath/qa/cppunit | |
parent | 646e52adf4a84ca5beab7bae1e1fae4e793c4896 (diff) |
starmath: Simplify code parsing nospace
This also comes with its unit test.
Change-Id: I1478bf48c5522691978e3534c9c8a9c0ddfc1e59
Reviewed-on: https://gerrit.libreoffice.org/35985
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_parse.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/starmath/qa/cppunit/test_parse.cxx b/starmath/qa/cppunit/test_parse.cxx index 80da700be4cc..4e7198e5db0e 100644 --- a/starmath/qa/cppunit/test_parse.cxx +++ b/starmath/qa/cppunit/test_parse.cxx @@ -33,9 +33,11 @@ public: private: void testMinus(); + void testNospace(); CPPUNIT_TEST_SUITE(ParseTest); CPPUNIT_TEST(testMinus); + CPPUNIT_TEST(testNospace); CPPUNIT_TEST_SUITE_END(); SmDocShellRef mxDocShell; @@ -90,6 +92,35 @@ void ParseTest::testMinus() static_cast<const SmTextNode *>(pNode001)->GetToken().aText); } +/* + * This shows that "nospace" turns off the expression's IsUseExtraSpaces(), + * but leaves its decendants' flag on. + */ +void ParseTest::testNospace() +{ + std::unique_ptr<SmTableNode> pNode(SmParser().Parse("nospace{ nitalic d {F(x) G(x)} }")); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pNode->GetNumSubNodes()); + const SmNode *pNode0 = pNode->GetSubNode(0); + CPPUNIT_ASSERT(pNode0); + CPPUNIT_ASSERT_EQUAL(NLINE, pNode0->GetType()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pNode0->GetNumSubNodes()); + const SmNode *pNode00 = pNode0->GetSubNode(0); + CPPUNIT_ASSERT(pNode00); + CPPUNIT_ASSERT_EQUAL(NEXPRESSION, pNode00->GetType()); + CPPUNIT_ASSERT(!static_cast<const SmExpressionNode *>(pNode00)->IsUseExtraSpaces()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), pNode00->GetNumSubNodes()); + const SmNode *pNode000 = pNode00->GetSubNode(0); + CPPUNIT_ASSERT(pNode000); + CPPUNIT_ASSERT_EQUAL(NFONT, pNode000->GetType()); + CPPUNIT_ASSERT_EQUAL(OUString("nitalic"), + static_cast<const SmFontNode *>(pNode000)->GetToken().aText); + const SmNode *pNode001 = pNode00->GetSubNode(1); + CPPUNIT_ASSERT(pNode001); + CPPUNIT_ASSERT_EQUAL(NEXPRESSION, pNode001->GetType()); + CPPUNIT_ASSERT(static_cast<const SmExpressionNode *>(pNode001)->IsUseExtraSpaces()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), pNode00->GetNumSubNodes()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ParseTest); } |