[Libreoffice-commits] core.git: starmath/qa

Takeshi Abe tabe at fixedpoint.jp
Tue Feb 28 02:35:05 UTC 2017


 starmath/qa/cppunit/test_starmath.cxx |  143 ++++++++++++++++++++++++++++++++++
 1 file changed, 143 insertions(+)

New commits:
commit 3015572007fcce57ee66ec45b4bc342fbce11332
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Mon Feb 27 23:06:07 2017 +0900

    starmath: Add test cases for errors at parsing
    
    Change-Id: Ic8de7f1c925d7a77520681121cbdd00c036ccab8
    Reviewed-on: https://gerrit.libreoffice.org/34683
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Takeshi Abe <tabe at fixedpoint.jp>

diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx
index 852cf6a..becdcc5 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -44,6 +44,19 @@ public:
     void editUndoRedo();
     void editMarker();
     void editFailure();
+    void ParseErrorUnexpectedToken();
+    void ParseErrorPoundExpected();
+    void ParseErrorColorExpected();
+    void ParseErrorLgroupExpected();
+    void ParseErrorRgroupExpected();
+    void ParseErrorLbraceExpected();
+    void ParseErrorRbraceExpected();
+    void ParseErrorParentMismatch();
+    void ParseErrorRightExpected();
+    void ParseErrorFontExpected();
+    void ParseErrorSizeExpected();
+    void ParseErrorDoubleAlign();
+    void ParseErrorDoubleSubsupscript();
 
     void replacePlaceholder();
     void viewZoom();
@@ -52,6 +65,19 @@ public:
     CPPUNIT_TEST(editUndoRedo);
     CPPUNIT_TEST(editMarker);
     CPPUNIT_TEST(editFailure);
+    CPPUNIT_TEST(ParseErrorUnexpectedToken);
+    CPPUNIT_TEST(ParseErrorPoundExpected);
+    CPPUNIT_TEST(ParseErrorColorExpected);
+    CPPUNIT_TEST(ParseErrorLgroupExpected);
+    CPPUNIT_TEST(ParseErrorRgroupExpected);
+    CPPUNIT_TEST(ParseErrorLbraceExpected);
+    CPPUNIT_TEST(ParseErrorRbraceExpected);
+    CPPUNIT_TEST(ParseErrorParentMismatch);
+    CPPUNIT_TEST(ParseErrorRightExpected);
+    CPPUNIT_TEST(ParseErrorFontExpected);
+    CPPUNIT_TEST(ParseErrorSizeExpected);
+    CPPUNIT_TEST(ParseErrorDoubleAlign);
+    CPPUNIT_TEST(ParseErrorDoubleSubsupscript);
     CPPUNIT_TEST(replacePlaceholder);
     CPPUNIT_TEST(viewZoom);
     CPPUNIT_TEST_SUITE_END();
@@ -186,6 +212,123 @@ void Test::editFailure()
         pLastErrorDesc && pLastErrorDesc == pErrorDesc);
 }
 
+void Test::ParseErrorUnexpectedToken()
+{
+    m_xDocShRef->SetText("\\foo");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::UnexpectedToken expected",
+                           SmParseError::UnexpectedToken == pErrorDesc->m_eType);
+}
+
+void Test::ParseErrorPoundExpected()
+{
+    m_xDocShRef->SetText("matrix {1#2##a##b#c}");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::PoundExpected expected",
+                           SmParseError::PoundExpected == pErrorDesc->m_eType);
+}
+
+void Test::ParseErrorColorExpected()
+{
+    m_xDocShRef->SetText("color 42 x");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::ColorExpected expected",
+                           SmParseError::ColorExpected == pErrorDesc->m_eType);
+}
+
+void Test::ParseErrorLgroupExpected()
+{
+    m_xDocShRef->SetText("stack 42");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::LgroupExpected expected",
+                           SmParseError::LgroupExpected == pErrorDesc->m_eType);
+}
+
+void Test::ParseErrorRgroupExpected()
+{
+    m_xDocShRef->SetText("stack {a#b#c)");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::RgroupExpected expected",
+                           SmParseError::RgroupExpected == pErrorDesc->m_eType);
+}
+
+void Test::ParseErrorLbraceExpected()
+{
+    m_xDocShRef->SetText("left 42");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::LbraceExpected expected",
+                           SmParseError::LbraceExpected == pErrorDesc->m_eType);
+}
+
+void Test::ParseErrorRbraceExpected()
+{
+    m_xDocShRef->SetText("left ( foo right x");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::RbraceExpected expected",
+                           SmParseError::RbraceExpected == pErrorDesc->m_eType);
+}
+
+void Test::ParseErrorParentMismatch()
+{
+    m_xDocShRef->SetText("lbrace foo rceil");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::ParentMismatch expected",
+                           SmParseError::ParentMismatch == pErrorDesc->m_eType);
+}
+
+void Test::ParseErrorRightExpected()
+{
+    m_xDocShRef->SetText("left ( x mline y )");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::RightExpected expected",
+                           SmParseError::RightExpected == pErrorDesc->m_eType);
+}
+
+void Test::ParseErrorFontExpected()
+{
+    m_xDocShRef->SetText("font small bar");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::FontExpected expected",
+                           SmParseError::FontExpected == pErrorDesc->m_eType);
+}
+
+void Test::ParseErrorSizeExpected()
+{
+    m_xDocShRef->SetText("size small baz");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::SizeExpected expected",
+                           SmParseError::SizeExpected == pErrorDesc->m_eType);
+}
+
+void Test::ParseErrorDoubleAlign()
+{
+    m_xDocShRef->SetText("alignl alignc x");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::DoubleAlign expected",
+                           SmParseError::DoubleAlign == pErrorDesc->m_eType);
+}
+
+void Test::ParseErrorDoubleSubsupscript()
+{
+    m_xDocShRef->SetText("x_y_z");
+    const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
+    CPPUNIT_ASSERT(pErrorDesc);
+    CPPUNIT_ASSERT_MESSAGE("SmParseError::DoubleSubsupscript expected",
+                           SmParseError::DoubleSubsupscript == pErrorDesc->m_eType);
+}
+
 void Test::editUndoRedo()
 {
     EditEngine &rEditEngine = m_xDocShRef->GetEditEngine();


More information about the Libreoffice-commits mailing list