[Libreoffice-commits] .: 3 commits - sal/inc sal/qa

Lubos Lunak llunak at kemper.freedesktop.org
Wed Mar 28 00:07:59 PDT 2012


 sal/inc/rtl/string.hxx                             |  306 +++++++++++++++++++--
 sal/qa/rtl/strings/test_ostring_stringliterals.cxx |   88 +++++-
 2 files changed, 369 insertions(+), 25 deletions(-)

New commits:
commit 2ebda60bfe7897ac371dd7ee97c4309e72f20e4b
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Mar 28 08:56:05 2012 +0200

    more SFINAE to distinguish between const char* and const char[]

diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index e7db97b..0593ddf 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -799,18 +799,8 @@ public:
 
     friend sal_Bool     operator == ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
                         { return rStr1.getLength() == rStr2.getLength() && rStr1.compareTo( rStr2 ) == 0; }
-    friend sal_Bool     operator == ( const OString& rStr1, const sal_Char * pStr2 ) SAL_THROW(())
-                        { return rStr1.compareTo( pStr2 ) == 0; }
-    friend sal_Bool     operator == ( const sal_Char * pStr1,   const OString& rStr2 ) SAL_THROW(())
-                        { return OString( pStr1 ).compareTo( rStr2 ) == 0; }
-
     friend sal_Bool     operator != ( const OString& rStr1,     const OString& rStr2 ) SAL_THROW(())
                         { return !(operator == ( rStr1, rStr2 )); }
-    friend sal_Bool     operator != ( const OString& rStr1, const sal_Char * pStr2 ) SAL_THROW(())
-                        { return !(operator == ( rStr1, pStr2 )); }
-    friend sal_Bool     operator != ( const sal_Char * pStr1,   const OString& rStr2 ) SAL_THROW(())
-                        { return !(operator == ( pStr1, rStr2 )); }
-
     friend sal_Bool     operator <  ( const OString& rStr1,    const OString& rStr2 ) SAL_THROW(())
                         { return rStr1.compareTo( rStr2 ) < 0; }
     friend sal_Bool     operator >  ( const OString& rStr1,    const OString& rStr2 ) SAL_THROW(())
@@ -820,6 +810,18 @@ public:
     friend sal_Bool     operator >= ( const OString& rStr1,    const OString& rStr2 ) SAL_THROW(())
                         { return rStr1.compareTo( rStr2 ) >= 0; }
 
+    template< typename T >
+    friend typename internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value ) SAL_THROW(())
+    {
+        return rStr1.compareTo( value ) == 0;
+    }
+
+    template< typename T >
+    friend typename internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 ) SAL_THROW(())
+    {
+        return rStr2.compareTo( value ) == 0;
+    }
+
     /**
      @overload
      This function accepts an ASCII string literal as its argument.
@@ -829,8 +831,8 @@ public:
     friend bool operator == ( const OString& rStr, const char (&literal)[ N ] ) SAL_THROW(())
     {
         RTL_STRING_CONST_FUNCTION
-        return rStr.getLength() == N - 1 && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length,
-            literal, N - 1 );
+        return rStr.getLength() == N - 1
+            && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, literal, N - 1 ) == 0;
     }
 
     /**
@@ -856,8 +858,8 @@ public:
     friend bool operator == ( const char (&literal)[ N ], const OString& rStr ) SAL_THROW(())
     {
         RTL_STRING_CONST_FUNCTION
-        return rStr.getLength() == N - 1 && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length,
-            literal, N - 1 );
+        return rStr.getLength() == N - 1
+            && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, literal, N - 1 ) == 0;
     }
 
     /**
@@ -874,6 +876,18 @@ public:
         return rStr.compareTo( value ) == 0;
     }
 
+    template< typename T >
+    friend typename internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value ) SAL_THROW(())
+    {
+        return !(operator == ( rStr1, value ));
+    }
+
+    template< typename T >
+    friend typename internal::CharPtrDetector< T, bool >::Type operator!=( const T& value,   const OString& rStr2 ) SAL_THROW(())
+    {
+        return !(operator == ( value, rStr2 ));
+    }
+
     /**
      @overload
      This function accepts an ASCII string literal as its argument.
diff --git a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
index 0ada709..4af152c 100644
--- a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
+++ b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
@@ -149,20 +149,48 @@ void test::ostring::StringLiterals::checkUsage()
 
     rtl_string_unittest_const_literal = false; // start checking for OString conversions
     rtl_string_unittest_non_const_literal_function = false; // and check for non-const variants
+    rtl_string_unittest_const_literal_function = false;
     CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = "foo" );
+    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+    rtl_string_unittest_const_literal_function = false;
     CPPUNIT_ASSERT( FoO.equalsIgnoreAsciiCase( "fOo" ));
+    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+    rtl_string_unittest_const_literal_function = false;
     CPPUNIT_ASSERT( foobarfoo.match( "bar", 3 ));
+    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+    rtl_string_unittest_const_literal_function = false;
     CPPUNIT_ASSERT( foobar.match( "foo" ));
+    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+    rtl_string_unittest_const_literal_function = false;
     CPPUNIT_ASSERT( FooBaRfoo.matchIgnoreAsciiCase( "bAr", 3 ));
+    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+    rtl_string_unittest_const_literal_function = false;
     CPPUNIT_ASSERT( FooBaR.matchIgnoreAsciiCase( "fOo" ));
+    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+    rtl_string_unittest_const_literal_function = false;
     CPPUNIT_ASSERT( foobar.endsWith( "bar" ));
+    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+//    rtl_string_unittest_const_literal_function = false;
 //    CPPUNIT_ASSERT( FooBaR.endsWithIgnoreAsciiCase( "bar" ));
+//    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+    rtl_string_unittest_const_literal_function = false;
     CPPUNIT_ASSERT( foo == "foo" );
+    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+    rtl_string_unittest_const_literal_function = false;
     CPPUNIT_ASSERT( "foo" == foo );
+    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+    rtl_string_unittest_const_literal_function = false;
     CPPUNIT_ASSERT( foo != "bar" );
+    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+    rtl_string_unittest_const_literal_function = false;
     CPPUNIT_ASSERT( "foo" != bar );
+    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+    rtl_string_unittest_const_literal_function = false;
     CPPUNIT_ASSERT( foobarfoo.indexOf( "foo", 1 ) == 6 );
+    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
+//    rtl_string_unittest_const_literal_function = false;
 //    CPPUNIT_ASSERT( foobarfoo.lastIndexOf( "foo" ) == 6 );
+//    CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
     // if this is not true, some of the calls above converted to OString
     CPPUNIT_ASSERT( rtl_string_unittest_const_literal == false );
     // if this is not true, some of the calls above used non-const variants
commit 86ebc8471d5e056a1240e5f9d487c5b1c9b3d423
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Mar 28 08:13:47 2012 +0200

    hopefully only OString ctors do not work with SFINAE broken

diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index 19430fd..e7db97b 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -91,7 +91,6 @@ namespace rtl
   use this class.
 */
 
-#ifndef HAVE_SFINAE_ANONYMOUS_BROKEN
 namespace internal
 {
 // This template is used for SFINAE (Substitution failure is not an error), to detect that
@@ -114,7 +113,6 @@ struct CharPtrDetector< char*, T >
     typedef T Type;
 };
 }
-#endif
 
 class OString
 {
commit 3ba10632a34a4740e77da76d7aa5bda8a2eb99ab
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Mar 28 08:12:16 2012 +0200

    string literal overloads for rest of OString methods

diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index d899067..19430fd 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -99,19 +99,19 @@ namespace internal
 // Using a template appears to be the only way to distinguish char* and char[], since
 // using char*(&) does not work with something explicitly cast to char*.
 struct Dummy {};
-template< typename T >
+template< typename T1, typename T2 >
 struct CharPtrDetector
 {
 };
-template<>
-struct CharPtrDetector< const char* >
+template< typename T >
+struct CharPtrDetector< const char*, T >
 {
-    typedef Dummy Type;
+    typedef T Type;
 };
-template<>
-struct CharPtrDetector< char* >
+template< typename T >
+struct CharPtrDetector< char*, T >
 {
-    typedef Dummy Type;
+    typedef T Type;
 };
 }
 #endif
@@ -204,7 +204,7 @@ public:
      }
 #else
     template< typename T >
-    OString( const T& value, typename internal::CharPtrDetector< T >::Type = internal::Dummy() ) SAL_THROW(())
+    OString( const T& value, typename internal::CharPtrDetector< T, internal::Dummy >::Type = internal::Dummy() ) SAL_THROW(())
     {
         pData = 0;
         rtl_string_newFromStr( &pData, value );
@@ -314,8 +314,8 @@ public:
     template< int N >
     OString& operator=( const char (&literal)[ N ] ) SAL_THROW(())
     {
-        rtl_string_newFromLiteral( &pData, literal, N - 1 );
         RTL_STRING_CONST_FUNCTION
+        rtl_string_newFromLiteral( &pData, literal, N - 1 );
         return *this;
     }
     /**
@@ -532,16 +532,48 @@ public:
       127. The ASCII string must be NULL-terminated.
       This function can't be used for language specific comparison.
 
+      Note: The argument type is always either char* or const char*, the return type is bool.
+      The template is used only for technical reasons.
+
       @param    asciiStr        the 8-Bit ASCII character string to be compared.
       @return   sal_True if the strings are equal;
                 sal_False, otherwise.
     */
-    sal_Bool equalsIgnoreAsciiCase( const sal_Char * asciiStr ) const SAL_THROW(())
+    template< typename T >
+    typename internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase( const T& asciiStr ) const SAL_THROW(())
     {
         return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
     }
 
     /**
+     @overload
+     This function accepts an ASCII string literal as its argument.
+     @since LibreOffice 3.6
+    */
+    template< int N >
+    bool equalsIgnoreAsciiCase( const char (&literal)[ N ] ) const SAL_THROW(())
+    {
+        RTL_STRING_CONST_FUNCTION
+        if ( pData->length != N - 1 )
+            return false;
+        return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
+                                                          literal, N - 1 ) == 0;
+    }
+    /**
+      @overload
+      This function accepts a non-const char array as its argument.
+      @since LibreOffice 3.6
+
+      @param value non-const char array
+    */
+    template< int N >
+    bool equalsIgnoreAsciiCase( char (&value)[ N ] ) const SAL_THROW(())
+    {
+        RTL_STRING_NON_CONST_FUNCTION
+        return rtl_str_compareIgnoreAsciiCase( pData->buffer, value ) == 0;
+    }
+
+    /**
       Perform a ASCII lowercase comparison of two strings.
 
       The result is true if and only if second string
@@ -591,6 +623,36 @@ public:
     }
 
     /**
+     @overload
+     This function accepts an ASCII string literal as its argument.
+     @since LibreOffice 3.6
+    */
+    template< int N >
+    bool match( const char (&literal)[ N ], sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+    {
+        RTL_STRING_CONST_FUNCTION
+        return rtl_str_shortenedCompare_WithLength(
+            pData->buffer + fromIndex, pData->length - fromIndex,
+            literal, N - 1, N - 1) == 0;
+    }
+    /**
+      @overload
+      This function accepts a non-const char array as its argument.
+      @since LibreOffice 3.6
+
+      @param value non-const char array
+    */
+    template< int N >
+    bool match( char (&value)[ N ], sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+    {
+        RTL_STRING_NON_CONST_FUNCTION
+        sal_Int32 strLength = rtl_str_getLength( value );
+        return rtl_str_shortenedCompare_WithLength(
+            pData->buffer + fromIndex, pData->length - fromIndex,
+            value, strLength, strLength) == 0;
+    }
+
+    /**
       Match against a substring appearing in this string.
 
       @param str  the substring to be compared; must not be null and must point
@@ -649,6 +711,34 @@ public:
     }
 
     /**
+     @overload
+     This function accepts an ASCII string literal as its argument.
+     @since LibreOffice 3.6
+    */
+    template< int N >
+    bool matchIgnoreAsciiCase( const char (&literal)[ N ], sal_Int32 fromIndex = 0 ) const
+    {
+        RTL_STRING_CONST_FUNCTION
+        return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+                                                                   literal, N - 1, N - 1 ) == 0;
+    }
+    /**
+      @overload
+      This function accepts a non-const char array as its argument.
+      @since LibreOffice 3.6
+
+      @param value non-const char array
+    */
+    template< int N >
+    bool matchIgnoreAsciiCase( char (&value)[ N ], sal_Int32 fromIndex = 0 ) const
+    {
+        RTL_STRING_NON_CONST_FUNCTION
+        sal_Int32 strLength = rtl_str_getLength( value );
+        return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+                                                                   value, strLength, strLength ) == 0;
+    }
+
+    /**
       Check whether this string ends with a given substring.
 
       @param str  the substring to be compared
@@ -664,6 +754,34 @@ public:
     }
 
     /**
+     @overload
+     This function accepts an ASCII string literal as its argument.
+     @since LibreOffice 3.6
+    */
+    template< int N >
+    bool endsWith( const char (&literal)[ N ] ) const
+    {
+        RTL_STRING_CONST_FUNCTION
+        return N - 1 <= getLength()
+            && match(literal, getLength() - ( N - 1 ));
+    }
+    /**
+      @overload
+      This function accepts a non-const char array as its argument.
+      @since LibreOffice 3.6
+
+      @param value non-const char array
+    */
+    template< int N >
+    bool endsWith( char (&value)[ N ] ) const
+    {
+        RTL_STRING_NON_CONST_FUNCTION
+        sal_Int32 strLength = rtl_str_getLength( value );
+        return strLength <= getLength()
+            && matchL(value, strLength, getLength() - strLength);
+    }
+
+    /**
       Check whether this string ends with a given substring.
 
       @param str  the substring to be compared; must not be null and must point
@@ -705,6 +823,108 @@ public:
                         { return rStr1.compareTo( rStr2 ) >= 0; }
 
     /**
+     @overload
+     This function accepts an ASCII string literal as its argument.
+     @since LibreOffice 3.6
+    */
+    template< int N >
+    friend bool operator == ( const OString& rStr, const char (&literal)[ N ] ) SAL_THROW(())
+    {
+        RTL_STRING_CONST_FUNCTION
+        return rStr.getLength() == N - 1 && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length,
+            literal, N - 1 );
+    }
+
+    /**
+      @overload
+      This function accepts a non-const char array as its argument.
+      @since LibreOffice 3.6
+
+      @param value non-const char array
+    */
+    template< int N >
+    friend bool operator == ( const OString& rStr, char (&value)[ N ] ) SAL_THROW(())
+    {
+        RTL_STRING_NON_CONST_FUNCTION
+        return rStr.compareTo( value ) == 0;
+    }
+
+    /**
+     @overload
+     This function accepts an ASCII string literal as its argument.
+     @since LibreOffice 3.6
+    */
+    template< int N >
+    friend bool operator == ( const char (&literal)[ N ], const OString& rStr ) SAL_THROW(())
+    {
+        RTL_STRING_CONST_FUNCTION
+        return rStr.getLength() == N - 1 && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length,
+            literal, N - 1 );
+    }
+
+    /**
+      @overload
+      This function accepts a non-const char array as its argument.
+      @since LibreOffice 3.6
+
+      @param value non-const char array
+    */
+    template< int N >
+    friend bool operator == ( char (&value)[ N ], const OString& rStr ) SAL_THROW(())
+    {
+        RTL_STRING_NON_CONST_FUNCTION
+        return rStr.compareTo( value ) == 0;
+    }
+
+    /**
+     @overload
+     This function accepts an ASCII string literal as its argument.
+     @since LibreOffice 3.6
+    */
+    template< int N >
+    friend bool operator != ( const OString& rStr, const char (&literal)[ N ] ) SAL_THROW(())
+    {
+        return !( rStr == literal );
+    }
+
+    /**
+      @overload
+      This function accepts a non-const char array as its argument.
+      @since LibreOffice 3.6
+
+      @param value non-const char array
+    */
+    template< int N >
+    friend bool operator != ( const OString& rStr, char (&value)[ N ] ) SAL_THROW(())
+    {
+        return !( rStr == value );
+    }
+
+    /**
+     @overload
+     This function accepts an ASCII string literal as its argument.
+     @since LibreOffice 3.6
+    */
+    template< int N >
+    friend bool operator != ( const char (&literal)[ N ], const OString& rStr ) SAL_THROW(())
+    {
+        return !( literal == rStr );
+    }
+
+    /**
+      @overload
+      This function accepts a non-const char array as its argument.
+      @since LibreOffice 3.6
+
+      @param value non-const char array
+    */
+    template< int N >
+    friend bool operator != ( char (&value)[ N ], const OString& rStr ) SAL_THROW(())
+    {
+        return !( value == rStr );
+    }
+
+    /**
       Returns a hashcode for this string.
 
       @return   a hash code value for this object.
@@ -789,6 +1009,36 @@ public:
     }
 
     /**
+     @overload
+     This function accepts an ASCII string literal as its argument.
+     @since LibreOffice 3.6
+    */
+    template< int N >
+    sal_Int32 indexOf( const char (&literal)[ N ], sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+    {
+        RTL_STRING_CONST_FUNCTION
+        sal_Int32 n = rtl_str_indexOfStr_WithLength(
+            pData->buffer + fromIndex, pData->length - fromIndex, literal, N - 1);
+        return n < 0 ? n : n + fromIndex;
+    }
+
+    /**
+      @overload
+      This function accepts a non-const char array as its argument.
+      @since LibreOffice 3.6
+
+      @param value non-const char array
+    */
+    template< int N >
+    sal_Int32 indexOf( char (&value)[ N ], sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+    {
+        RTL_STRING_NON_CONST_FUNCTION
+        sal_Int32 n = rtl_str_indexOfStr_WithLength(
+            pData->buffer + fromIndex, pData->length - fromIndex, value, rtl_str_getLength( value ));
+        return n < 0 ? n : n + fromIndex;
+    }
+
+    /**
       Returns the index within this string of the first occurrence of the
       specified substring, starting at the specified index.
 
diff --git a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
index d665ee2..0ada709 100644
--- a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
+++ b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
@@ -139,10 +139,30 @@ void test::ostring::StringLiterals::checkUsage()
 // simply check that all string literal based calls work as expected
 // also check that they really use string literal overload and do not convert to OString
     rtl::OString foo( "foo" );
+    rtl::OString FoO( "FoO" );
+    rtl::OString foobarfoo( "foobarfoo" );
+    rtl::OString foobar( "foobar" );
+    rtl::OString FooBaRfoo( "FooBaRfoo" );
+    rtl::OString FooBaR( "FooBaR" );
+    rtl::OString bar( "bar" );
+    rtl::OString test( "test" );
 
     rtl_string_unittest_const_literal = false; // start checking for OString conversions
     rtl_string_unittest_non_const_literal_function = false; // and check for non-const variants
     CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = "foo" );
+    CPPUNIT_ASSERT( FoO.equalsIgnoreAsciiCase( "fOo" ));
+    CPPUNIT_ASSERT( foobarfoo.match( "bar", 3 ));
+    CPPUNIT_ASSERT( foobar.match( "foo" ));
+    CPPUNIT_ASSERT( FooBaRfoo.matchIgnoreAsciiCase( "bAr", 3 ));
+    CPPUNIT_ASSERT( FooBaR.matchIgnoreAsciiCase( "fOo" ));
+    CPPUNIT_ASSERT( foobar.endsWith( "bar" ));
+//    CPPUNIT_ASSERT( FooBaR.endsWithIgnoreAsciiCase( "bar" ));
+    CPPUNIT_ASSERT( foo == "foo" );
+    CPPUNIT_ASSERT( "foo" == foo );
+    CPPUNIT_ASSERT( foo != "bar" );
+    CPPUNIT_ASSERT( "foo" != bar );
+    CPPUNIT_ASSERT( foobarfoo.indexOf( "foo", 1 ) == 6 );
+//    CPPUNIT_ASSERT( foobarfoo.lastIndexOf( "foo" ) == 6 );
     // if this is not true, some of the calls above converted to OString
     CPPUNIT_ASSERT( rtl_string_unittest_const_literal == false );
     // if this is not true, some of the calls above used non-const variants
@@ -153,14 +173,48 @@ void test::ostring::StringLiterals::checkNonConstUsage()
 {
 // check that (non-const) char[] overloads work and do not use const char[] overloads
     rtl::OString foo( "foo" );
+    rtl::OString FoO( "FoO" );
+    rtl::OString foobarfoo( "foobarfoo" );
+    rtl::OString foobar( "foobar" );
+    rtl::OString FooBaRfoo( "FooBaRfoo" );
+    rtl::OString FooBaR( "FooBaR" );
+    rtl::OString bar( "bar" );
+    rtl::OString test( "test" );
     char foo_c[] = "foo";
+    char bar_c[] = "bar";
+    char fOo_c[] = "fOo";
+    char bAr_c[] = "bAr";
 
     rtl_string_unittest_const_literal = false; // start checking for OString conversions
     rtl_string_unittest_const_literal_function = false; // and check for const variants
-    CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = (const char*)"foo" );
+    CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = (const char*)foo_c );
     CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = foo_c );
-    // if this is not true, some of the calls above converted to OString
-    CPPUNIT_ASSERT( rtl_string_unittest_const_literal == false );
+    CPPUNIT_ASSERT( FoO.equalsIgnoreAsciiCase( (const char*)fOo_c ));
+    CPPUNIT_ASSERT( FoO.equalsIgnoreAsciiCase( fOo_c ));
+    CPPUNIT_ASSERT( foobarfoo.match( (const char*)bar_c, 3 ));
+    CPPUNIT_ASSERT( foobarfoo.match( bar_c, 3 ));
+    CPPUNIT_ASSERT( foobar.match( (const char*)foo_c ));
+    CPPUNIT_ASSERT( foobar.match( foo_c ));
+    CPPUNIT_ASSERT( FooBaRfoo.matchIgnoreAsciiCase( (const char*)bAr_c, 3 ));
+    CPPUNIT_ASSERT( FooBaRfoo.matchIgnoreAsciiCase( bAr_c, 3 ));
+    CPPUNIT_ASSERT( FooBaR.matchIgnoreAsciiCase( (const char*)fOo_c ));
+    CPPUNIT_ASSERT( FooBaR.matchIgnoreAsciiCase( fOo_c ));
+    CPPUNIT_ASSERT( foobar.endsWith( (const char*)bar_c ));
+    CPPUNIT_ASSERT( foobar.endsWith( bar_c ));
+//    CPPUNIT_ASSERT( FooBaR.endsWithIgnoreAsciiCase( (const char*)bar_c ));
+//    CPPUNIT_ASSERT( FooBaR.endsWithIgnoreAsciiCase( bar_c ));
+    CPPUNIT_ASSERT( foo == (const char*)foo_c );
+    CPPUNIT_ASSERT( foo == foo_c );
+    CPPUNIT_ASSERT( (const char*)foo_c == foo );
+    CPPUNIT_ASSERT( foo_c == foo );
+    CPPUNIT_ASSERT( foo != (const char*)bar_c );
+    CPPUNIT_ASSERT( foo != bar_c );
+    CPPUNIT_ASSERT( (const char*)foo_c != bar );
+    CPPUNIT_ASSERT( foo_c != bar );
+    CPPUNIT_ASSERT( foobarfoo.indexOf( (const char*)foo_c, 1 ) == 6 );
+    CPPUNIT_ASSERT( foobarfoo.indexOf( foo_c, 1 ) == 6 );
+//    CPPUNIT_ASSERT( foobarfoo.lastIndexOf( (const char*)foo_c ) == 6 );
+//    CPPUNIT_ASSERT( foobarfoo.lastIndexOf( foo_c ) == 6 );
     // if this is not true, some of the calls above used const variants
     CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == false );
 }


More information about the Libreoffice-commits mailing list