LCOV - code coverage report
Current view: top level - basic/qa/cppunit - test_append.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 24 24 100.0 %
Date: 2014-04-11 Functions: 11 12 91.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include "basictest.hxx"
      11             : #include <osl/file.hxx>
      12             : #include <osl/process.h>
      13             : 
      14             : #include <basic/sbmod.hxx>
      15             : #include <basic/sbmeth.hxx>
      16             : namespace
      17             : {
      18           4 :     class EnableTest : public test::BootstrapFixture
      19             :     {
      20             :         public:
      21           2 :         EnableTest() : BootstrapFixture(true, false) {};
      22             :         void testDimEnable();
      23             :         void testEnableRuntime();
      24             :         // Adds code needed to register the test suite
      25           2 :         CPPUNIT_TEST_SUITE(EnableTest);
      26             : 
      27             :         // Declares the method as a test to call
      28           1 :         CPPUNIT_TEST(testDimEnable);
      29           1 :         CPPUNIT_TEST(testEnableRuntime);
      30             : 
      31             :         // End of test suite definition
      32           2 :         CPPUNIT_TEST_SUITE_END();
      33             :     };
      34             : 
      35           2 : OUString sTestEnableRuntime(
      36             :     "Function doUnitTest as Integer\n"
      37             :     "Dim Enable as Integer\n"
      38             :     "Enable = 1\n"
      39             :     "Enable = Enable + 2\n"
      40             :     "doUnitTest = Enable\n"
      41             :     "End Function\n"
      42           1 : );
      43             : 
      44           2 : OUString sTestDimEnable(
      45             :     "Sub doUnitTest\n"
      46             :     "Dim Enable as String\n"
      47             :     "End Sub\n"
      48           1 : );
      49             : 
      50           1 : void EnableTest::testEnableRuntime()
      51             : {
      52           1 :     MacroSnippet myMacro(sTestEnableRuntime);
      53           1 :     myMacro.Compile();
      54           1 :     CPPUNIT_ASSERT_MESSAGE("testEnableRuntime fails with compile error",!myMacro.HasError() );
      55           2 :     SbxVariableRef pNew = myMacro.Run();
      56           2 :     CPPUNIT_ASSERT(pNew->GetInteger() == 3 );
      57           1 : }
      58             : 
      59           1 : void EnableTest::testDimEnable()
      60             : {
      61           1 :     MacroSnippet myMacro(sTestDimEnable);
      62           1 :     myMacro.Compile();
      63           1 :     CPPUNIT_ASSERT_MESSAGE("Dim causes compile error", !myMacro.HasError() );
      64           1 : }
      65             : 
      66             :   // Put the test suite in the registry
      67           1 :   CPPUNIT_TEST_SUITE_REGISTRATION(EnableTest);
      68             : } // namespace
      69           4 : CPPUNIT_PLUGIN_IMPLEMENT();
      70             : 
      71             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10