Kaydet (Commit) 240f9bcb authored tarafından Stephan Bergmann's avatar Stephan Bergmann

No need for RTL_FAST_STRING in addition to LIBO_INTERNAL_ONLY

Change-Id: I5514898f588b21bafceefca95e3276826cb9a882
üst d5c86be0
...@@ -190,7 +190,7 @@ inline Any SAL_CALL makeAny( bool const & value ) ...@@ -190,7 +190,7 @@ inline Any SAL_CALL makeAny( bool const & value )
} }
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
template< class C1, class C2 > template< class C1, class C2 >
inline Any SAL_CALL makeAny( const rtl::OUStringConcat< C1, C2 >& value ) inline Any SAL_CALL makeAny( const rtl::OUStringConcat< C1, C2 >& value )
{ {
...@@ -220,7 +220,7 @@ inline void SAL_CALL operator <<= ( Any & rAny, bool const & value ) ...@@ -220,7 +220,7 @@ inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
} }
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
template< class C1, class C2 > template< class C1, class C2 >
inline void SAL_CALL operator <<= ( Any & rAny, const rtl::OUStringConcat< C1, C2 >& value ) inline void SAL_CALL operator <<= ( Any & rAny, const rtl::OUStringConcat< C1, C2 >& value )
{ {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <rtl/string.hxx> #include <rtl/string.hxx>
#include <rtl/stringutils.hxx> #include <rtl/stringutils.hxx>
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
#include <rtl/stringconcat.hxx> #include <rtl/stringconcat.hxx>
#endif #endif
...@@ -214,7 +214,7 @@ public: ...@@ -214,7 +214,7 @@ public:
rtl_stringbuffer_newFromStr_WithLength( &pData, value, length ); rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
} }
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/** /**
@overload @overload
@internal @internal
...@@ -495,7 +495,7 @@ public: ...@@ -495,7 +495,7 @@ public:
return *this; return *this;
} }
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/** /**
@overload @overload
@internal @internal
...@@ -940,21 +940,6 @@ public: ...@@ -940,21 +940,6 @@ public:
return *this; return *this;
} }
#ifdef LIBO_INTERNAL_ONLY
// This is to complement the RTL_FAST_STRING operator+, which allows any combination of valid operands,
// even two buffers. It's intentional it returns OString, just like the operator+ would in the fast variant.
#ifndef RTL_FAST_STRING
/**
@internal
@since LibreOffice 4.1
*/
friend OString operator+( const OStringBuffer& str1, const OStringBuffer& str2 )
{
return OString( str1.pData ).concat( str2.pData );
}
#endif
#endif
private: private:
/** /**
A pointer to the data structure which contains the data. A pointer to the data structure which contains the data.
...@@ -967,7 +952,7 @@ private: ...@@ -967,7 +952,7 @@ private:
sal_Int32 nCapacity; sal_Int32 nCapacity;
}; };
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/** /**
@internal @internal
*/ */
...@@ -992,7 +977,7 @@ typedef rtlunittest::OStringBuffer OStringBuffer; ...@@ -992,7 +977,7 @@ typedef rtlunittest::OStringBuffer OStringBuffer;
#undef RTL_STRING_CONST_FUNCTION #undef RTL_STRING_CONST_FUNCTION
#endif #endif
#ifdef LIBO_INTERNAL_ONLY #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
using ::rtl::OStringBuffer; using ::rtl::OStringBuffer;
#endif #endif
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <rtl/string.h> #include <rtl/string.h>
#include <rtl/stringutils.hxx> #include <rtl/stringutils.hxx>
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
#include <rtl/stringconcat.hxx> #include <rtl/stringconcat.hxx>
#endif #endif
...@@ -231,7 +231,7 @@ public: ...@@ -231,7 +231,7 @@ public:
} }
} }
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/** /**
@overload @overload
@internal @internal
...@@ -297,7 +297,7 @@ public: ...@@ -297,7 +297,7 @@ public:
return *this; return *this;
} }
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/** /**
@overload @overload
@internal @internal
...@@ -1128,7 +1128,7 @@ public: ...@@ -1128,7 +1128,7 @@ public:
return OString( pNew, SAL_NO_ACQUIRE ); return OString( pNew, SAL_NO_ACQUIRE );
} }
#ifndef RTL_FAST_STRING #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
friend OString operator+( const OString & str1, const OString & str2 ) friend OString operator+( const OString & str1, const OString & str2 )
{ {
return str1.concat( str2 ); return str1.concat( str2 );
...@@ -1634,7 +1634,7 @@ public: ...@@ -1634,7 +1634,7 @@ public:
/* ======================================================================= */ /* ======================================================================= */
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/** /**
A simple wrapper around string literal. It is usually not necessary to use, can A simple wrapper around string literal. It is usually not necessary to use, can
be mostly used to force OString operator+ working with operands that otherwise would be mostly used to force OString operator+ working with operands that otherwise would
...@@ -1684,11 +1684,6 @@ inline std::basic_ostream<charT, traits> & operator <<( ...@@ -1684,11 +1684,6 @@ inline std::basic_ostream<charT, traits> & operator <<(
{ {
return stream << OString( concat ); return stream << OString( concat );
} }
#else
// non-RTL_FAST_STRING needs this to compile
/// @cond INTERNAL
typedef OString OStringLiteral;
/// @endcond
#endif #endif
...@@ -1752,7 +1747,7 @@ typedef rtlunittest::OString OString; ...@@ -1752,7 +1747,7 @@ typedef rtlunittest::OString OString;
#undef RTL_STRING_CONST_FUNCTION #undef RTL_STRING_CONST_FUNCTION
#endif #endif
#ifdef LIBO_INTERNAL_ONLY #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
using ::rtl::OString; using ::rtl::OString;
using ::rtl::OStringHash; using ::rtl::OStringHash;
using ::rtl::OStringLiteral; using ::rtl::OStringLiteral;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <string.h> #include <string.h>
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
#ifdef RTL_STRING_UNITTEST #ifdef RTL_STRING_UNITTEST
#define rtl rtlunittest #define rtl rtlunittest
......
...@@ -13,12 +13,6 @@ ...@@ -13,12 +13,6 @@
#include <sal/config.h> #include <sal/config.h>
#include <sal/types.h> #include <sal/types.h>
// This feature is not part of public API and is meant to be used only internally by LibreOffice.
#ifdef LIBO_INTERNAL_ONLY
// Enable fast string concatenation.
#define RTL_FAST_STRING
#endif
// The unittest uses slightly different code to help check that the proper // The unittest uses slightly different code to help check that the proper
// calls are made. The class is put into a different namespace to make // calls are made. The class is put into a different namespace to make
// sure the compiler generates a different (if generating also non-inline) // sure the compiler generates a different (if generating also non-inline)
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <rtl/stringutils.hxx> #include <rtl/stringutils.hxx>
#include <sal/types.h> #include <sal/types.h>
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
#include <rtl/stringconcat.hxx> #include <rtl/stringconcat.hxx>
#endif #endif
...@@ -184,7 +184,7 @@ public: ...@@ -184,7 +184,7 @@ public:
} }
#endif #endif
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/** /**
@overload @overload
@internal @internal
...@@ -493,7 +493,7 @@ public: ...@@ -493,7 +493,7 @@ public:
return *this; return *this;
} }
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/** /**
@overload @overload
@internal @internal
...@@ -1395,21 +1395,6 @@ public: ...@@ -1395,21 +1395,6 @@ public:
return OUStringBuffer( pNew, count + 16 ); return OUStringBuffer( pNew, count + 16 );
} }
#ifdef LIBO_INTERNAL_ONLY
// This is to complement the RTL_FAST_STRING operator+, which allows any combination of valid operands,
// even two buffers. It's intentional it returns OUString, just like the operator+ would in the fast variant.
#ifndef RTL_FAST_STRING
/**
@internal
@since LibreOffice 4.1
*/
friend OUString operator+( const OUStringBuffer& str1, const OUStringBuffer& str2 )
{
return OUString( str1.pData ).concat( str2.pData );
}
#endif
#endif
private: private:
OUStringBuffer( rtl_uString * value, const sal_Int32 capacity ) OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
{ {
...@@ -1428,7 +1413,7 @@ private: ...@@ -1428,7 +1413,7 @@ private:
sal_Int32 nCapacity; sal_Int32 nCapacity;
}; };
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/** /**
@internal @internal
*/ */
...@@ -1451,7 +1436,7 @@ typedef rtlunittest::OUStringBuffer OUStringBuffer; ...@@ -1451,7 +1436,7 @@ typedef rtlunittest::OUStringBuffer OUStringBuffer;
} }
#endif #endif
#ifdef LIBO_INTERNAL_ONLY #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
using ::rtl::OUStringBuffer; using ::rtl::OUStringBuffer;
#endif #endif
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <rtl/textenc.h> #include <rtl/textenc.h>
#include <sal/log.hxx> #include <sal/log.hxx>
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
#include <rtl/stringconcat.hxx> #include <rtl/stringconcat.hxx>
#endif #endif
...@@ -53,7 +53,7 @@ namespace rtl ...@@ -53,7 +53,7 @@ namespace rtl
#undef rtl #undef rtl
#endif #endif
#if defined RTL_FAST_STRING #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/// @cond INTERNAL /// @cond INTERNAL
/** /**
...@@ -250,7 +250,7 @@ public: ...@@ -250,7 +250,7 @@ public:
} }
#endif #endif
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/// @cond INTERNAL /// @cond INTERNAL
/** /**
New string from an 8-Bit string literal that is expected to contain only New string from an 8-Bit string literal that is expected to contain only
...@@ -324,7 +324,7 @@ public: ...@@ -324,7 +324,7 @@ public:
} }
} }
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/** /**
@overload @overload
@internal @internal
...@@ -400,7 +400,7 @@ public: ...@@ -400,7 +400,7 @@ public:
return *this; return *this;
} }
#if defined RTL_FAST_STRING #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/// @cond INTERNAL /// @cond INTERNAL
/** Assign a new string from a single ASCII character literal. /** Assign a new string from a single ASCII character literal.
...@@ -425,7 +425,7 @@ public: ...@@ -425,7 +425,7 @@ public:
return *this; return *this;
} }
#ifdef RTL_FAST_STRING #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/** /**
@overload @overload
@internal @internal
...@@ -1575,7 +1575,7 @@ public: ...@@ -1575,7 +1575,7 @@ public:
return OUString( pNew, SAL_NO_ACQUIRE ); return OUString( pNew, SAL_NO_ACQUIRE );
} }
#ifndef RTL_FAST_STRING #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
friend OUString operator+( const OUString& rStr1, const OUString& rStr2 ) friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
{ {
return rStr1.concat( rStr2 ); return rStr1.concat( rStr2 );
...@@ -2413,7 +2413,7 @@ public: ...@@ -2413,7 +2413,7 @@ public:
} }
}; };
#if defined RTL_FAST_STRING #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/// @cond INTERNAL /// @cond INTERNAL
/** Compare a string and an ASCII character literal for equality. /** Compare a string and an ASCII character literal for equality.
...@@ -2436,12 +2436,6 @@ template<char C> bool operator !=( ...@@ -2436,12 +2436,6 @@ template<char C> bool operator !=(
return !(string == literal); return !(string == literal);
} }
/// @endcond
#endif
/* ======================================================================= */
#ifdef RTL_FAST_STRING
/** /**
@internal @internal
*/ */
...@@ -2487,10 +2481,7 @@ inline std::basic_ostream<charT, traits> & operator <<( ...@@ -2487,10 +2481,7 @@ inline std::basic_ostream<charT, traits> & operator <<(
{ {
return stream << OUString( concat ); return stream << OUString( concat );
} }
#else
// non-RTL_FAST_STRING needs this to compile
/// @cond INTERNAL
typedef OUString OUStringLiteral;
/// @endcond /// @endcond
#endif #endif
...@@ -2596,16 +2587,14 @@ typedef rtlunittest::OUString OUString; ...@@ -2596,16 +2587,14 @@ typedef rtlunittest::OUString OUString;
// In internal code, allow to use classes like OUString without having to // In internal code, allow to use classes like OUString without having to
// explicitly refer to the rtl namespace, which is kind of superfluous given // explicitly refer to the rtl namespace, which is kind of superfluous given
// that OUString itself is namespaced by its OU prefix: // that OUString itself is namespaced by its OU prefix:
#ifdef LIBO_INTERNAL_ONLY #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
using ::rtl::OUString; using ::rtl::OUString;
using ::rtl::OUStringHash; using ::rtl::OUStringHash;
using ::rtl::OStringToOUString; using ::rtl::OStringToOUString;
using ::rtl::OUStringToOString; using ::rtl::OUStringToOString;
using ::rtl::OUStringLiteral; using ::rtl::OUStringLiteral;
#if defined RTL_FAST_STRING
using ::rtl::OUStringLiteral1; using ::rtl::OUStringLiteral1;
#endif #endif
#endif
#endif /* _RTL_USTRING_HXX */ #endif /* _RTL_USTRING_HXX */
......
...@@ -52,40 +52,35 @@ CPPUNIT_TEST(checkInvalid); ...@@ -52,40 +52,35 @@ CPPUNIT_TEST(checkInvalid);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
#ifdef RTL_FAST_STRING
#define TYPES_ASSERT_EQUAL( a, b ) CPPUNIT_ASSERT_EQUAL( a, b )
#else
#define TYPES_ASSERT_EQUAL( a, b )
#endif
void test::ostring::StringConcat::checkConcat() void test::ostring::StringConcat::checkConcat()
{ {
// All the extra () are to protect commas against being treated as separators of macro arguments. // All the extra () are to protect commas against being treated as separators of macro arguments.
CPPUNIT_ASSERT_EQUAL( OString(), OString(OString() + OString())); CPPUNIT_ASSERT_EQUAL( OString(), OString(OString() + OString()));
CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OString( "foo" ) + OString( "bar" ))); CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OString( "foo" ) + OString( "bar" )));
TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OString, OString > )), typeid( OString( "foo" ) + OString( "bar" ))); CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OString, OString > )), typeid( OString( "foo" ) + OString( "bar" )));
CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OString( "foo" ) + "bar" )); CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OString( "foo" ) + "bar" ));
TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OString, const char[ 4 ] > )), typeid( OString( "foo" ) + "bar" )); CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OString, const char[ 4 ] > )), typeid( OString( "foo" ) + "bar" ));
CPPUNIT_ASSERT_EQUAL( OString( "foobarbaz" ), OString( OString( "foo" ) + "bar" + "baz" )); CPPUNIT_ASSERT_EQUAL( OString( "foobarbaz" ), OString( OString( "foo" ) + "bar" + "baz" ));
TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OStringConcat< OString, const char[ 4 ] >, const char[ 4 ] > )), typeid( OString( "foo" ) + "bar" + "baz" )); CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringConcat< OString, const char[ 4 ] >, const char[ 4 ] > )), typeid( OString( "foo" ) + "bar" + "baz" ));
CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringLiteral( "foo" ) + "bar" )); CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringLiteral( "foo" ) + "bar" ));
TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OStringLiteral, const char[ 4 ] > )), typeid( OStringLiteral( "foo" ) + "bar" )); CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringLiteral, const char[ 4 ] > )), typeid( OStringLiteral( "foo" ) + "bar" ));
CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringLiteral( "foo" ) + (const char*)"bar" )); CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringLiteral( "foo" ) + (const char*)"bar" ));
TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OStringLiteral, const char* > )), typeid( OStringLiteral( "foo" ) + (const char*)"bar" )); CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringLiteral, const char* > )), typeid( OStringLiteral( "foo" ) + (const char*)"bar" ));
const char d1[] = "xyz"; const char d1[] = "xyz";
char d2[] = "abc"; char d2[] = "abc";
const char* d3 = d1; const char* d3 = d1;
char* d4 = d2; char* d4 = d2;
CPPUNIT_ASSERT_EQUAL( OString( "fooxyz" ), OString( OString( "foo" ) + d1 )); CPPUNIT_ASSERT_EQUAL( OString( "fooxyz" ), OString( OString( "foo" ) + d1 ));
TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OString, const char[ 4 ] > )), typeid( OString( "foo" ) + d1 )); CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OString, const char[ 4 ] > )), typeid( OString( "foo" ) + d1 ));
CPPUNIT_ASSERT_EQUAL( OString( "fooabc" ), OString( OString( "foo" ) + d2 )); CPPUNIT_ASSERT_EQUAL( OString( "fooabc" ), OString( OString( "foo" ) + d2 ));
TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OString, char[ 4 ] > )), typeid( OString( "foo" ) + d2 )); CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OString, char[ 4 ] > )), typeid( OString( "foo" ) + d2 ));
CPPUNIT_ASSERT_EQUAL( OString( "fooxyz" ), OString( OString( "foo" ) + d3 )); CPPUNIT_ASSERT_EQUAL( OString( "fooxyz" ), OString( OString( "foo" ) + d3 ));
TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OString, const char* > )), typeid( OString( "foo" ) + d3 )); CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OString, const char* > )), typeid( OString( "foo" ) + d3 ));
CPPUNIT_ASSERT_EQUAL( OString( "fooabc" ), OString( OString( "foo" ) + d4 )); CPPUNIT_ASSERT_EQUAL( OString( "fooabc" ), OString( OString( "foo" ) + d4 ));
TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OString, char* > )), typeid( OString( "foo" ) + d4 )); CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OString, char* > )), typeid( OString( "foo" ) + d4 ));
#ifdef __GNUC__ #ifdef __GNUC__
CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringBuffer( "foo" ) + OString( "bar" ))); CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringBuffer( "foo" ) + OString( "bar" )));
TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OStringBuffer, OString > )), typeid( OStringBuffer( "foo" ) + OString( "bar" ))); CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringBuffer, OString > )), typeid( OStringBuffer( "foo" ) + OString( "bar" )));
#endif #endif
} }
...@@ -145,7 +140,6 @@ void test::ostring::StringConcat::checkAppend() ...@@ -145,7 +140,6 @@ void test::ostring::StringConcat::checkAppend()
void test::ostring::StringConcat::checkInvalid() void test::ostring::StringConcat::checkInvalid()
{ {
#ifdef RTL_FAST_STRING
CPPUNIT_ASSERT( !INVALID_CONCAT( OString() + OString())); CPPUNIT_ASSERT( !INVALID_CONCAT( OString() + OString()));
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUString( "b" ))); CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUString( "b" )));
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUStringBuffer( "b" ))); CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUStringBuffer( "b" )));
...@@ -155,7 +149,6 @@ void test::ostring::StringConcat::checkInvalid() ...@@ -155,7 +149,6 @@ void test::ostring::StringConcat::checkInvalid()
rtl_uString* rus = NULL; rtl_uString* rus = NULL;
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rs )); CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rs ));
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rus )); CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rus ));
#endif
} }
}} // namespace }} // namespace
......
...@@ -52,28 +52,23 @@ CPPUNIT_TEST(checkInvalid); ...@@ -52,28 +52,23 @@ CPPUNIT_TEST(checkInvalid);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
#ifdef RTL_FAST_STRING
#define TYPES_ASSERT_EQUAL( a, b ) CPPUNIT_ASSERT_EQUAL( a, b )
#else
#define TYPES_ASSERT_EQUAL( a, b )
#endif
void test::oustring::StringConcat::checkConcat() void test::oustring::StringConcat::checkConcat()
{ {
// All the extra () are to protect commas against being treated as separators of macro arguments. // All the extra () are to protect commas against being treated as separators of macro arguments.
CPPUNIT_ASSERT_EQUAL( OUString(), OUString(OUString() + OUString())); CPPUNIT_ASSERT_EQUAL( OUString(), OUString(OUString() + OUString()));
CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString( "foo" ) + OUString( "bar" ))); CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString( "foo" ) + OUString( "bar" )));
TYPES_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, OUString > )), typeid( OUString( "foo" ) + OUString( "bar" ))); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, OUString > )), typeid( OUString( "foo" ) + OUString( "bar" )));
CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString( "foo" ) + "bar" )); CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString( "foo" ) + "bar" ));
TYPES_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( OUString( "foo" ) + "bar" )); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( OUString( "foo" ) + "bar" ));
CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), OUString( OUString( "foo" ) + "bar" + "baz" )); CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), OUString( OUString( "foo" ) + "bar" + "baz" ));
TYPES_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< OUString, const char[ 4 ] >, const char[ 4 ] > )), typeid( OUString( "foo" ) + "bar" + "baz" )); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< OUString, const char[ 4 ] >, const char[ 4 ] > )), typeid( OUString( "foo" ) + "bar" + "baz" ));
CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringLiteral( "foo" ) + "bar" )); CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringLiteral( "foo" ) + "bar" ));
TYPES_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringLiteral, const char[ 4 ] > )), typeid( OUStringLiteral( "foo" ) + "bar" )); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringLiteral, const char[ 4 ] > )), typeid( OUStringLiteral( "foo" ) + "bar" ));
const char d1[] = "xyz"; const char d1[] = "xyz";
CPPUNIT_ASSERT_EQUAL( OUString( "fooxyz" ), OUString( OUString( "foo" ) + d1 )); CPPUNIT_ASSERT_EQUAL( OUString( "fooxyz" ), OUString( OUString( "foo" ) + d1 ));
TYPES_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( OUString( "foo" ) + d1 )); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( OUString( "foo" ) + d1 ));
CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringBuffer( "foo" ) + OUString( "bar" ))); CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringBuffer( "foo" ) + OUString( "bar" )));
TYPES_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringBuffer, OUString > )), typeid( OUStringBuffer( "foo" ) + OUString( "bar" ))); CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringBuffer, OUString > )), typeid( OUStringBuffer( "foo" ) + OUString( "bar" )));
} }
void test::oustring::StringConcat::checkEnsureCapacity() void test::oustring::StringConcat::checkEnsureCapacity()
...@@ -136,7 +131,6 @@ void test::oustring::StringConcat::checkAppend() ...@@ -136,7 +131,6 @@ void test::oustring::StringConcat::checkAppend()
void test::oustring::StringConcat::checkInvalid() void test::oustring::StringConcat::checkInvalid()
{ {
#ifdef RTL_FAST_STRING
CPPUNIT_ASSERT( !INVALID_CONCAT( OUString() + OUString())); CPPUNIT_ASSERT( !INVALID_CONCAT( OUString() + OUString()));
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OString( "b" ))); CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OString( "b" )));
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OStringBuffer( "b" ))); CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OStringBuffer( "b" )));
...@@ -150,8 +144,6 @@ void test::oustring::StringConcat::checkInvalid() ...@@ -150,8 +144,6 @@ void test::oustring::StringConcat::checkInvalid()
rtl_uString* rus = NULL; rtl_uString* rus = NULL;
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rs )); CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rs ));
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rus )); CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rus ));
#endif
} }
}} // namespace }} // namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment