LCOV - code coverage report
Current view: top level - basic/qa/cppunit - test_append.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 35 35 100.0 %
Date: 2012-08-25 Functions: 11 12 91.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 116 236 49.2 %

           Branch data     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         [ -  + ]:         12 :     class EnableTest : public BasicTestBase
      19                 :            :     {
      20                 :            :         public:
      21                 :          6 :         EnableTest() {};
      22                 :            :         void testDimEnable();
      23                 :            :         void testEnableRuntime();
      24                 :            :         // Adds code needed to register the test suite
      25 [ +  - ][ +  - ]:          6 :         CPPUNIT_TEST_SUITE(EnableTest);
         [ +  - ][ +  - ]
                 [ #  # ]
      26                 :            : 
      27                 :            :         // Declares the method as a test to call
      28 [ +  - ][ +  - ]:          3 :         CPPUNIT_TEST(testDimEnable);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      29 [ +  - ][ +  - ]:          3 :         CPPUNIT_TEST(testEnableRuntime);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      30                 :            : 
      31                 :            :         // End of test suite definition
      32 [ +  - ][ +  - ]:          6 :         CPPUNIT_TEST_SUITE_END();
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      33                 :            :     };
      34                 :            : 
      35                 :          3 : rtl::OUString sTestEnableRuntime(
      36                 :            :     "Function Test as Integer\n"
      37                 :            :     "Dim Enable as Integer\n"
      38                 :            :     "Enable = 1\n"
      39                 :            :     "Enable = Enable + 2\n"
      40                 :            :     "Test = Enable\n"
      41                 :            :     "End Function\n"
      42                 :          3 : );
      43                 :            : 
      44                 :          3 : rtl::OUString sTestDimEnable(
      45                 :            :     "Sub Test\n"
      46                 :            :     "Dim Enable as String\n"
      47                 :            :     "End Sub\n"
      48                 :          3 : );
      49                 :            : 
      50                 :          3 : void EnableTest::testEnableRuntime()
      51                 :            : {
      52 [ +  - ][ +  - ]:          3 :     CPPUNIT_ASSERT_MESSAGE( "No resource manager", basicDLL().GetBasResMgr() != NULL );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      53 [ +  - ][ +  - ]:          3 :     StarBASICRef pBasic = new StarBASIC();
      54         [ +  - ]:          3 :     ResetError();
      55 [ +  - ][ +  - ]:          3 :     StarBASIC::SetGlobalErrorHdl( LINK( this, EnableTest, BasicErrorHdl ) );
      56                 :            : 
      57 [ +  - ][ +  - ]:          3 :     SbModule* pMod = pBasic->MakeModule( rtl::OUString( "TestModule" ), sTestEnableRuntime );
         [ +  - ][ +  - ]
                 [ +  - ]
      58         [ +  - ]:          3 :     pMod->Compile();
      59 [ +  - ][ +  - ]:          3 :     CPPUNIT_ASSERT_MESSAGE("testEnableRuntime fails with compile error",!HasError() );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      60         [ +  - ]:          3 :     SbMethod* pMeth = static_cast<SbMethod*>(pMod->Find( rtl::OUString("Test"),  SbxCLASS_METHOD ));
      61 [ +  - ][ +  - ]:          3 :     CPPUNIT_ASSERT_MESSAGE("testEnableRuntime no method found", pMeth );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      62                 :          3 :     SbxVariableRef refTemp = pMeth;
      63                 :            :     // forces a broadcast
      64 [ +  - ][ +  - ]:          3 :     SbxVariableRef pNew = new  SbxMethod( *((SbxMethod*)pMeth));
      65 [ +  - ][ +  - ]:          3 :     CPPUNIT_ASSERT(pNew->GetInteger() == 3 );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      66                 :          3 : }
      67                 :            : 
      68                 :          3 : void EnableTest::testDimEnable()
      69                 :            : {
      70 [ +  - ][ +  - ]:          3 :     CPPUNIT_ASSERT_MESSAGE( "No resource manager", basicDLL().GetBasResMgr() != NULL );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      71 [ +  - ][ +  - ]:          3 :     StarBASICRef pBasic = new StarBASIC();
      72 [ +  - ][ +  - ]:          3 :     StarBASIC::SetGlobalErrorHdl( LINK( this, EnableTest, BasicErrorHdl ) );
      73                 :            : 
      74         [ +  - ]:          3 :     ResetError();
      75                 :            : 
      76 [ +  - ][ +  - ]:          3 :     SbModule* pMod = pBasic->MakeModule( rtl::OUString( "TestModule" ), sTestDimEnable );
         [ +  - ][ +  - ]
                 [ +  - ]
      77         [ +  - ]:          3 :     pMod->Compile();
      78                 :            : 
      79 [ +  - ][ +  - ]:          3 :     CPPUNIT_ASSERT_MESSAGE("Dim causes compile error", !HasError() );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      80                 :          3 : }
      81                 :            : 
      82                 :            :   // Put the test suite in the registry
      83                 :          3 :   CPPUNIT_TEST_SUITE_REGISTRATION(EnableTest);
      84                 :            : } // namespace
      85 [ +  - ][ +  - ]:         12 : CPPUNIT_PLUGIN_IMPLEMENT();
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
      86                 :            : 
      87                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10