LCOV - code coverage report
Current view: top level - basic/qa/cppunit - test_append.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 24 24 100.0 %
Date: 2014-11-03 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           8 :     class EnableTest : public test::BootstrapFixture
      19             :     {
      20             :         public:
      21           4 :         EnableTest() : BootstrapFixture(true, false) {};
      22             :         void testDimEnable();
      23             :         void testEnableRuntime();
      24             :         // Adds code needed to register the test suite
      25           4 :         CPPUNIT_TEST_SUITE(EnableTest);
      26             : 
      27             :         // Declares the method as a test to call
      28           2 :         CPPUNIT_TEST(testDimEnable);
      29           2 :         CPPUNIT_TEST(testEnableRuntime);
      30             : 
      31             :         // End of test suite definition
      32           4 :         CPPUNIT_TEST_SUITE_END();
      33             :     };
      34             : 
      35           4 : 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           2 : );
      43             : 
      44           4 : OUString sTestDimEnable(
      45             :     "Sub doUnitTest\n"
      46             :     "Dim Enable as String\n"
      47             :     "End Sub\n"
      48           2 : );
      49             : 
      50           2 : void EnableTest::testEnableRuntime()
      51             : {
      52           2 :     MacroSnippet myMacro(sTestEnableRuntime);
      53           2 :     myMacro.Compile();
      54           2 :     CPPUNIT_ASSERT_MESSAGE("testEnableRuntime fails with compile error",!myMacro.HasError() );
      55           4 :     SbxVariableRef pNew = myMacro.Run();
      56           4 :     CPPUNIT_ASSERT(pNew->GetInteger() == 3 );
      57           2 : }
      58             : 
      59           2 : void EnableTest::testDimEnable()
      60             : {
      61           2 :     MacroSnippet myMacro(sTestDimEnable);
      62           2 :     myMacro.Compile();
      63           2 :     CPPUNIT_ASSERT_MESSAGE("Dim causes compile error", !myMacro.HasError() );
      64           2 : }
      65             : 
      66             :   // Put the test suite in the registry
      67           2 :   CPPUNIT_TEST_SUITE_REGISTRATION(EnableTest);
      68             : } // namespace
      69           8 : CPPUNIT_PLUGIN_IMPLEMENT();
      70             : 
      71             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10