summaryrefslogtreecommitdiffstats
path: root/starmath/qa
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2017-02-27 23:06:07 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2017-02-28 02:34:36 +0000
commit3015572007fcce57ee66ec45b4bc342fbce11332 (patch)
tree21fa1bb3712ecccdfbaa1093b6d42c269bca8553 /starmath/qa
parentuitest: catch more exceptions during shutdown (diff)
downloadcore-3015572007fcce57ee66ec45b4bc342fbce11332.tar.gz
core-3015572007fcce57ee66ec45b4bc342fbce11332.zip
starmath: Add test cases for errors at parsing
Change-Id: Ic8de7f1c925d7a77520681121cbdd00c036ccab8 Reviewed-on: https://gerrit.libreoffice.org/34683 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath/qa')
-rw-r--r--starmath/qa/cppunit/test_starmath.cxx143
1 files changed, 143 insertions, 0 deletions
diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx
index 852cf6abf1bb..becdcc5f6ec0 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();