LCOV - code coverage report
Current view: top level - sal/qa/osl/profile - osl_old_testprofile.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 24 95.8 %
Date: 2012-08-25 Functions: 10 11 90.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 36 78 46.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <sal/types.h>
      30                 :            : #include "cppunit/TestAssert.h"
      31                 :            : #include "cppunit/TestFixture.h"
      32                 :            : #include "cppunit/extensions/HelperMacros.h"
      33                 :            : #include "cppunit/plugin/TestPlugIn.h"
      34                 :            : 
      35                 :            : #include <stdio.h>
      36                 :            : #include <osl/profile.h>
      37                 :            : 
      38                 :            : //==================================================================================================
      39                 :            : // -----------------------------------------------------------------------------
      40                 :            : namespace osl_Profile
      41                 :            : {
      42         [ -  + ]:         15 :     class oldtests : public CppUnit::TestFixture
      43                 :            :     {
      44                 :            :     public:
      45                 :            :         void test_profile();
      46                 :            : 
      47 [ +  - ][ +  - ]:         10 :         CPPUNIT_TEST_SUITE( oldtests );
         [ +  - ][ +  - ]
                 [ #  # ]
      48 [ +  - ][ +  - ]:          5 :         CPPUNIT_TEST( test_profile );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      49 [ +  - ][ +  - ]:         10 :         CPPUNIT_TEST_SUITE_END( );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      50                 :            :     };
      51                 :            : 
      52                 :          5 : void oldtests::test_profile(void)
      53                 :            : {
      54                 :            :     oslProfile hProfile;
      55                 :          5 :     rtl_uString* ustrProfileName=0;
      56                 :          5 :     rtl_uString* ustrProfileName2=0;
      57                 :            : 
      58                 :          5 :     rtl_uString_newFromAscii(&ustrProfileName,"//./tmp/soffice.ini");
      59                 :          5 :     rtl_uString_newFromAscii(&ustrProfileName2,"//./tmp/not_existing_path/soffice.ini");
      60                 :            : 
      61                 :            : 
      62                 :            :     // successful write
      63         [ +  - ]:          5 :     hProfile = osl_openProfile( ustrProfileName, 0 );
      64         [ +  - ]:          5 :     if (hProfile != 0)
      65                 :            :     {
      66 [ +  - ][ +  - ]:          5 :         if (! osl_writeProfileBool( hProfile, "testsection", "testbool", 1 ))
      67         [ +  - ]:          5 :             printf( "### cannot write into init file!\n" );
      68                 :            : 
      69         [ +  - ]:          5 :         osl_closeProfile( hProfile );
      70                 :            :     }
      71                 :            : 
      72                 :            :     // unsuccessful write
      73         [ +  - ]:          5 :     hProfile = osl_openProfile( ustrProfileName2, 0 );
      74         [ +  - ]:          5 :     if (hProfile != 0)
      75                 :            :     {
      76 [ +  - ][ -  + ]:          5 :         if (osl_writeProfileBool( hProfile, "testsection", "testbool", 1 ))
      77         [ #  # ]:          0 :             printf( "### unexpected success writing into test2.ini!\n" );
      78                 :            : 
      79         [ +  - ]:          5 :         osl_closeProfile( hProfile );
      80                 :            :     }
      81                 :            : 
      82                 :          5 :     rtl_uString_release(ustrProfileName);
      83                 :          5 :     rtl_uString_release(ustrProfileName2);
      84                 :          5 : }
      85                 :            : 
      86                 :            : } // namespace osl_Profile
      87                 :            : 
      88                 :            : // -----------------------------------------------------------------------------
      89                 :          5 : CPPUNIT_TEST_SUITE_REGISTRATION( osl_Profile::oldtests );
      90                 :            : 
      91                 :            : // -----------------------------------------------------------------------------
      92 [ +  - ][ +  - ]:         20 : CPPUNIT_PLUGIN_IMPLEMENT();
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
      93                 :            : 
      94                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10