LCOV - code coverage report
Current view: top level - sal/qa/rtl/strings - test_ostring_stringliterals.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 151 153 98.7 %
Date: 2012-08-25 Functions: 13 14 92.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 670 1358 49.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4                 :            :  *
       5                 :            :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :            :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :            :  * the License or as specified alternatively below. You may obtain a copy of
       8                 :            :  * the License at http://www.mozilla.org/MPL/
       9                 :            :  *
      10                 :            :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :            :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :            :  * for the specific language governing rights and limitations under the
      13                 :            :  * License.
      14                 :            :  *
      15                 :            :  * Major Contributor(s):
      16                 :            :  * Copyright (C) 2012 Lubos Lunak <l.lunak@suse.cz> (initial developer)
      17                 :            :  *
      18                 :            :  * All Rights Reserved.
      19                 :            :  *
      20                 :            :  * For minor contributions see the git repository.
      21                 :            :  *
      22                 :            :  * Alternatively, the contents of this file may be used under the terms of
      23                 :            :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24                 :            :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25                 :            :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26                 :            :  * instead of those above.
      27                 :            :  */
      28                 :            : 
      29                 :            : // activate the extra needed ctor
      30                 :            : #define RTL_STRING_UNITTEST
      31                 :            : bool rtl_string_unittest_const_literal;
      32                 :            : bool rtl_string_unittest_invalid_conversion;
      33                 :            : bool rtl_string_unittest_const_literal_function;
      34                 :            : bool rtl_string_unittest_non_const_literal_function;
      35                 :            : 
      36                 :            : #include <sal/types.h>
      37                 :            : #include <cppunit/TestFixture.h>
      38                 :            : #include <cppunit/extensions/HelperMacros.h>
      39                 :            : #include "rtl/string.h"
      40                 :            : #include "rtl/string.hxx"
      41                 :            : #include "rtl/strbuf.hxx"
      42                 :            : 
      43                 :            : namespace rtlunittest {
      44                 :            : 
      45                 :            : template< typename charT, typename traits > std::basic_ostream<charT, traits> &
      46                 :          0 : operator <<(
      47                 :            :     std::basic_ostream<charT, traits> & stream, rtl::OString const & string)
      48                 :            : {
      49                 :          0 :     return stream << string.getStr();
      50                 :            :         // best effort; potentially loses data due to embedded null characters
      51                 :            : }
      52                 :            : 
      53                 :            : }
      54                 :            : 
      55                 :            : namespace test { namespace ostring {
      56                 :            : 
      57         [ -  + ]:         60 : class StringLiterals: public CppUnit::TestFixture
      58                 :            : {
      59                 :            : private:
      60                 :            :     void checkCtors();
      61                 :            :     void checkUsage();
      62                 :            :     void checkNonConstUsage();
      63                 :            :     void checkBuffer();
      64                 :            : 
      65                 :            :     void testcall( const char str[] );
      66                 :            : 
      67                 :            :     static const char bad5[];
      68                 :            :     static char bad6[];
      69                 :            : 
      70 [ +  - ][ +  - ]:         10 : CPPUNIT_TEST_SUITE(StringLiterals);
         [ +  - ][ +  - ]
                 [ #  # ]
      71 [ +  - ][ +  - ]:          5 : CPPUNIT_TEST(checkCtors);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      72 [ +  - ][ +  - ]:          5 : CPPUNIT_TEST(checkUsage);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      73 [ +  - ][ +  - ]:          5 : CPPUNIT_TEST(checkNonConstUsage);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      74 [ +  - ][ +  - ]:          5 : CPPUNIT_TEST(checkBuffer);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      75 [ +  - ][ +  - ]:         10 : CPPUNIT_TEST_SUITE_END();
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      76                 :            : };
      77                 :            : 
      78                 :            : // reset the flag, call OString ctor with the given argument and return
      79                 :            : // whether the string literal ctor was used
      80                 :            : #define CONST_CTOR_USED( argument ) \
      81                 :            :     ( \
      82                 :            :     rtl_string_unittest_const_literal = false, \
      83                 :            :     ( void ) rtl::OString( argument ), \
      84                 :            :     result_tmp = rtl_string_unittest_const_literal, \
      85                 :            :     rtl_string_unittest_const_literal = false, \
      86                 :            :     ( void ) rtl::OStringBuffer( argument ), \
      87                 :            :     rtl_string_unittest_const_literal && result_tmp )
      88                 :            : 
      89                 :          5 : void test::ostring::StringLiterals::checkCtors()
      90                 :            : {
      91                 :            : // string literal ctors do not work with SFINAE broken and are disabled
      92                 :            : #ifndef HAVE_SFINAE_ANONYMOUS_BROKEN
      93                 :            :     bool result_tmp;
      94 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( CONST_CTOR_USED( "test" ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ -  + ][ +  - ]
         [ +  - ][ +  - ]
      95                 :          5 :     const char good1[] = "test";
      96 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( CONST_CTOR_USED( good1 ));
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      97                 :            : 
      98 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( !CONST_CTOR_USED( (const char*) "test" ));
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ #  # ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      99                 :          5 :     const char* bad1 = good1;
     100 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( !CONST_CTOR_USED( bad1 ));
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ #  # ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     101                 :          5 :     char bad2[] = "test";
     102 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( !CONST_CTOR_USED( bad2 ));
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ #  # ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     103                 :          5 :     char* bad3 = bad2;
     104 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( !CONST_CTOR_USED( bad3 ));
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ #  # ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     105                 :          5 :     const char* bad4[] = { "test1" };
     106 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( !CONST_CTOR_USED( bad4[ 0 ] ));
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ #  # ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     107         [ +  - ]:          5 :     testcall( good1 );
     108                 :            : #ifndef _MSC_VER
     109                 :            :     // this is actually not supposed to work (see discussion in stringutils.hxx),
     110                 :            :     // but gcc and clang somehow manage, so keep it used, just in case some other problem
     111                 :            :     // shows up somewhen in the future
     112 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( !CONST_CTOR_USED( bad5 )); // size is not known here
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ -  + ][ #  # ]
         [ +  - ][ +  - ]
                 [ +  - ]
     113 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( !CONST_CTOR_USED( bad6 ));
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ #  # ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     114                 :            : #endif
     115                 :            : 
     116                 :            : // This one is technically broken, since the first element is 6 characters test\0\0,
     117                 :            : // but there does not appear a way to detect this by compile time (runtime will complain).
     118                 :            : // RTL_CONSTASCII_USTRINGPARAM() has the same flaw.
     119                 :          5 :     const char bad7[][ 6 ] = { "test", "test2" };
     120 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( CONST_CTOR_USED( bad7[ 0 ] ));
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     121 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( CONST_CTOR_USED( bad7[ 1 ] ));
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     122                 :            : 
     123                 :            : // Check that contents are correct and equal to the case when const char* ctor is used.
     124 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl::OString( (const char*)"" ) == rtl::OString( "" ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     125 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl::OString( (const char*)"ab" ) == rtl::OString( "ab" ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     126                 :            : 
     127                 :            : // Check that contents are correct and equal to the case when RTL_CONSTASCII_STRINGPARAM is used.
     128 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl::OString( RTL_CONSTASCII_STRINGPARAM( "" )) == rtl::OString( "" ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     129 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl::OString( RTL_CONSTASCII_STRINGPARAM( "ab" )) == rtl::OString( "ab" ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     130                 :            : #if 0
     131                 :            : // This is currently disabled because it can't be consistent with HAVE_SFINAE_ANONYMOUS_BROKEN.
     132                 :            : // Since the situation wasn't quite consistent even before, there should be no big harm.
     133                 :            : 
     134                 :            : // Check also that embedded \0 is included (RTL_CONSTASCII_STRINGPARAM does the same,
     135                 :            : // const char* ctor does not, but it seems to make more sense to include it when
     136                 :            : // it's explicitly mentioned in the string literal).
     137                 :            :     CPPUNIT_ASSERT( rtl::OString( RTL_CONSTASCII_STRINGPARAM( "\0" )) == rtl::OString( "\0" ));
     138                 :            :     CPPUNIT_ASSERT( rtl::OString( RTL_CONSTASCII_STRINGPARAM( "a\0b" )) == rtl::OString( "a\0b" ));
     139                 :            : #endif
     140                 :            : #endif
     141                 :          5 : }
     142                 :            : 
     143                 :            : const char test::ostring::StringLiterals::bad5[] = "test";
     144                 :            : char test::ostring::StringLiterals::bad6[] = "test";
     145                 :            : 
     146                 :          5 : void test::ostring::StringLiterals::testcall( const char str[] )
     147                 :            : {
     148                 :            : #ifndef _MSC_VER
     149                 :            :     bool result_tmp;
     150 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( !CONST_CTOR_USED( str ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ -  + ][ #  # ]
         [ +  - ][ +  - ]
                 [ +  - ]
     151                 :            : #else
     152                 :            :     // MSVC just errors out on this for some reason, which is fine as well
     153                 :            :     (void)str;
     154                 :            : #endif
     155                 :          5 : }
     156                 :            : 
     157                 :          5 : void test::ostring::StringLiterals::checkUsage()
     158                 :            : {
     159                 :            : // simply check that all string literal based calls work as expected
     160                 :            : // also check that they really use string literal overload and do not convert to OString
     161                 :          5 :     rtl::OString foo( "foo" );
     162                 :          5 :     rtl::OString FoO( "FoO" );
     163                 :          5 :     rtl::OString foobarfoo( "foobarfoo" );
     164                 :          5 :     rtl::OString foobar( "foobar" );
     165                 :          5 :     rtl::OString FooBaRfoo( "FooBaRfoo" );
     166                 :          5 :     rtl::OString FooBaR( "FooBaR" );
     167                 :          5 :     rtl::OString bar( "bar" );
     168                 :          5 :     rtl::OString test( "test" );
     169                 :            : 
     170                 :          5 :     rtl_string_unittest_const_literal = false; // start checking for OString conversions
     171                 :          5 :     rtl_string_unittest_non_const_literal_function = false; // and check for non-const variants
     172                 :          5 :     rtl_string_unittest_const_literal_function = false;
     173 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = "foo" );
         [ +  - ][ +  - ]
                 [ +  - ]
     174 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     175                 :            : #ifndef HAVE_SFINAE_ANONYMOUS_BROKEN
     176                 :          5 :     rtl_string_unittest_const_literal_function = false;
     177 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( FoO.equalsIgnoreAsciiCase( "fOo" ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     178 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     179                 :            : #endif
     180                 :          5 :     rtl_string_unittest_const_literal_function = false;
     181 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foobarfoo.match( "bar", 3 ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     182 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     183                 :          5 :     rtl_string_unittest_const_literal_function = false;
     184 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foobar.match( "foo" ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     185 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     186                 :          5 :     rtl_string_unittest_const_literal_function = false;
     187 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( FooBaRfoo.matchIgnoreAsciiCase( "bAr", 3 ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     188 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     189                 :          5 :     rtl_string_unittest_const_literal_function = false;
     190 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( FooBaR.matchIgnoreAsciiCase( "fOo" ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     191 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     192                 :          5 :     rtl_string_unittest_const_literal_function = false;
     193 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foobar.endsWith( "bar" ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     194 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     195                 :            : //    rtl_string_unittest_const_literal_function = false;
     196                 :            : //    CPPUNIT_ASSERT( FooBaR.endsWithIgnoreAsciiCase( "bar" ));
     197                 :            : //    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
     198                 :          5 :     rtl_string_unittest_const_literal_function = false;
     199 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foo == "foo" );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     200 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     201                 :          5 :     rtl_string_unittest_const_literal_function = false;
     202 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( "foo" == foo );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     203 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     204                 :          5 :     rtl_string_unittest_const_literal_function = false;
     205 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foo != "bar" );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     206 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     207                 :          5 :     rtl_string_unittest_const_literal_function = false;
     208 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( "foo" != bar );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     209 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     210                 :          5 :     rtl_string_unittest_const_literal_function = false;
     211 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foobarfoo.indexOf( "foo", 1 ) == 6 );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     212 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     213                 :            : //    rtl_string_unittest_const_literal_function = false;
     214                 :            : //    CPPUNIT_ASSERT( foobarfoo.lastIndexOf( "foo" ) == 6 );
     215                 :            : //    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
     216                 :            :     // if this is not true, some of the calls above converted to OString
     217 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal == false );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     218                 :            :     // if this is not true, some of the calls above used non-const variants
     219 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_non_const_literal_function == false );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     220                 :          5 : }
     221                 :            : 
     222                 :          5 : void test::ostring::StringLiterals::checkNonConstUsage()
     223                 :            : {
     224                 :            : // check that (non-const) char[] overloads work and do not use const char[] overloads
     225                 :          5 :     rtl::OString foo( "foo" );
     226                 :          5 :     rtl::OString FoO( "FoO" );
     227                 :          5 :     rtl::OString foobarfoo( "foobarfoo" );
     228                 :          5 :     rtl::OString foobar( "foobar" );
     229                 :          5 :     rtl::OString FooBaRfoo( "FooBaRfoo" );
     230                 :          5 :     rtl::OString FooBaR( "FooBaR" );
     231                 :          5 :     rtl::OString bar( "bar" );
     232                 :          5 :     rtl::OString test( "test" );
     233                 :          5 :     char foo_c[] = "foo";
     234                 :          5 :     char bar_c[] = "bar";
     235                 :          5 :     char fOo_c[] = "fOo";
     236                 :          5 :     char bAr_c[] = "bAr";
     237                 :            : 
     238                 :          5 :     rtl_string_unittest_const_literal = false; // start checking for OString conversions
     239                 :          5 :     rtl_string_unittest_const_literal_function = false; // and check for const variants
     240 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = (const char*)foo_c );
         [ +  - ][ +  - ]
                 [ +  - ]
     241 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = foo_c );
         [ +  - ][ +  - ]
                 [ +  - ]
     242 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( FoO.equalsIgnoreAsciiCase( (const char*)fOo_c ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     243 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( FoO.equalsIgnoreAsciiCase( fOo_c ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     244 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foobarfoo.match( (const char*)bar_c, 3 ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     245 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foobarfoo.match( bar_c, 3 ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     246 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foobar.match( (const char*)foo_c ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     247 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foobar.match( foo_c ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     248 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( FooBaRfoo.matchIgnoreAsciiCase( (const char*)bAr_c, 3 ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     249 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( FooBaRfoo.matchIgnoreAsciiCase( bAr_c, 3 ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     250 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( FooBaR.matchIgnoreAsciiCase( (const char*)fOo_c ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     251 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( FooBaR.matchIgnoreAsciiCase( fOo_c ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     252 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foobar.endsWith( (const char*)bar_c ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     253 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foobar.endsWith( bar_c ));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     254                 :            : //    CPPUNIT_ASSERT( FooBaR.endsWithIgnoreAsciiCase( (const char*)bar_c ));
     255                 :            : //    CPPUNIT_ASSERT( FooBaR.endsWithIgnoreAsciiCase( bar_c ));
     256 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foo == (const char*)foo_c );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     257 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foo == foo_c );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     258 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( (const char*)foo_c == foo );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     259 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foo_c == foo );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     260 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foo != (const char*)bar_c );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     261 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foo != bar_c );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     262 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( (const char*)foo_c != bar );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     263 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foo_c != bar );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     264 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foobarfoo.indexOf( (const char*)foo_c, 1 ) == 6 );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     265 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( foobarfoo.indexOf( foo_c, 1 ) == 6 );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     266                 :            : //    CPPUNIT_ASSERT( foobarfoo.lastIndexOf( (const char*)foo_c ) == 6 );
     267                 :            : //    CPPUNIT_ASSERT( foobarfoo.lastIndexOf( foo_c ) == 6 );
     268                 :            :     // if this is not true, some of the calls above used const variants
     269 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal == false );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     270 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == false );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     271                 :          5 : }
     272                 :            : 
     273                 :          5 : void test::ostring::StringLiterals::checkBuffer()
     274                 :            : {
     275                 :          5 :     rtl::OStringBuffer buf;
     276                 :            : #ifndef HAVE_SFINAE_ANONYMOUS_BROKEN
     277                 :          5 :     rtl_string_unittest_const_literal_function = false;
     278         [ +  - ]:          5 :     buf.append( "foo" );
     279 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     280 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT_EQUAL( rtl::OString( "foo" ), buf.toString());
         [ +  - ][ +  - ]
                 [ +  - ]
     281                 :          5 :     rtl_string_unittest_const_literal_function = false;
     282         [ +  - ]:          5 :     buf.append( "bar" );
     283 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     284 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT_EQUAL( rtl::OString( "foobar" ), buf.toString());
         [ +  - ][ +  - ]
                 [ +  - ]
     285                 :          5 :     rtl_string_unittest_const_literal_function = false;
     286         [ +  - ]:          5 :     buf.insert( 3, "baz" );
     287 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     288 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT_EQUAL( rtl::OString( "foobazbar" ), buf.toString());
         [ +  - ][ +  - ]
                 [ +  - ]
     289                 :            : #else
     290                 :            :     buf.append( "foobazbar" );
     291                 :            : #endif
     292                 :            : 
     293                 :          5 :     rtl::OString foobazbard( "foobazbard" );
     294                 :          5 :     rtl::OString foodbazbard( "foodbazbard" );
     295                 :          5 :     rtl_string_unittest_const_literal = false; // start checking for OString conversions
     296                 :          5 :     rtl_string_unittest_const_literal_function = false; // and check for const variants
     297                 :          5 :     char d[] = "d";
     298 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT_EQUAL( foobazbard, buf.append( d ).toString());
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     299 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT_EQUAL( foodbazbard, buf.insert( 3, d ).toString() );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     300 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal == false );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     301 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == false );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     302                 :          5 : }
     303                 :            : 
     304                 :            : #undef CONST_CTOR_USED
     305                 :            : 
     306                 :            : }} // namespace
     307                 :            : 
     308 [ +  - ][ +  - ]:         15 : CPPUNIT_TEST_SUITE_REGISTRATION(test::ostring::StringLiterals);
     309                 :            : 
     310                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10