basic/qa/cppunit/test_nested_struct.cxx |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

New commits:
commit 23bfaf601d78ab2a80ec5493ef7eab1410975769
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Jul 21 00:14:14 2020 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jul 21 09:40:34 2020 +0200

    tdf#134576: basic_macros: Add unittest
    
    Change-Id: I6078e0712f7983159ea3b3f2060a1c4b69e9d5c6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99114
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/basic/qa/cppunit/test_nested_struct.cxx 
b/basic/qa/cppunit/test_nested_struct.cxx
index 009d832b1ce6..daced48ba2bf 100644
--- a/basic/qa/cppunit/test_nested_struct.cxx
+++ b/basic/qa/cppunit/test_nested_struct.cxx
@@ -28,6 +28,7 @@ namespace
         void testFixedVarAssign();
         void testFixedVarAssignAlt(); // result is uno-ised and tested
         void testUnoAccess(); // fdo#60117 specific test
+        void testTdf134576();
 
         // Adds code needed to register the test suite
         CPPUNIT_TEST_SUITE(Nested_Struct);
@@ -42,6 +43,7 @@ namespace
         CPPUNIT_TEST(testFixedVarAssign);
         CPPUNIT_TEST(testFixedVarAssignAlt);
         CPPUNIT_TEST(testUnoAccess);
+        CPPUNIT_TEST(testTdf134576);
 
         // End of test suite definition
         CPPUNIT_TEST_SUITE_END();
@@ -296,6 +298,24 @@ void Nested_Struct::testUnoAccess()
     CPPUNIT_ASSERT_EQUAL(200, result );
 }
 
+void Nested_Struct::testTdf134576()
+{
+    MacroSnippet myMacro("Function doUnitTest()\n"
+                        "  On Error Resume Next\n"
+                        "  For Each a In b\n"
+                        "    c.d\n"
+                        "  Next\n"
+                        "  doUnitTest = 1\n"
+                        "End Function\n");
+
+    myMacro.Compile();
+    CPPUNIT_ASSERT(!myMacro.HasError());
+
+    // Without the fix in place, it would have crashed here
+    SbxVariableRef pNew = myMacro.Run();
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), pNew->GetInteger());
+}
+
   // Put the test suite in the registry
   CPPUNIT_TEST_SUITE_REGISTRATION(Nested_Struct);
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to