diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-03-28 22:58:11 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-03-28 23:00:55 +0200 |
commit | ef87e804ec80451ff1517482c1b70e7dccb961ce (patch) | |
tree | 0f677f23738d6b94a1daa502a3a95e474dca9d60 /sal/qa/rtl | |
parent | b741f7fb1ea7b62c9cf2988a64e07cbbb8db904a (diff) |
string literal overloads for OStringBuffer
Diffstat (limited to 'sal/qa/rtl')
-rw-r--r-- | sal/qa/rtl/strings/test_ostring_stringliterals.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx index 462385ea23e5..3f2ed8465815 100644 --- a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx +++ b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx @@ -40,6 +40,7 @@ bool rtl_string_unittest_non_const_literal_function; #include <cppunit/extensions/HelperMacros.h> #include "rtl/string.h" #include "rtl/string.hxx" +#include "rtl/strbuf.hxx" namespace rtlunittest { @@ -61,6 +62,7 @@ private: void checkCtors(); void checkUsage(); void checkNonConstUsage(); + void checkBuffer(); void testcall( const char str[] ); @@ -68,6 +70,7 @@ CPPUNIT_TEST_SUITE(StringLiterals); CPPUNIT_TEST(checkCtors); CPPUNIT_TEST(checkUsage); CPPUNIT_TEST(checkNonConstUsage); +CPPUNIT_TEST(checkBuffer); CPPUNIT_TEST_SUITE_END(); }; @@ -247,6 +250,34 @@ void test::ostring::StringLiterals::checkNonConstUsage() // 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 == false ); + CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == false ); +} + +void test::ostring::StringLiterals::checkBuffer() +{ + rtl::OStringBuffer buf; + rtl_string_unittest_const_literal_function = false; + buf.append( "foo" ); + CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true ); + CPPUNIT_ASSERT_EQUAL( buf.toString(), rtl::OString( "foo" )); + rtl_string_unittest_const_literal_function = false; + buf.append( "bar" ); + CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true ); + CPPUNIT_ASSERT_EQUAL( buf.toString(), rtl::OString( "foobar" )); + rtl_string_unittest_const_literal_function = false; + buf.insert( 3, "baz" ); + CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true ); + CPPUNIT_ASSERT_EQUAL( buf.toString(), rtl::OString( "foobazbar" )); + + rtl::OString foobazbard( "foobazbard" ); + rtl::OString foodbazbard( "foodbazbard" ); + rtl_string_unittest_const_literal = false; // start checking for OString conversions + rtl_string_unittest_const_literal_function = false; // and check for const variants + char d[] = "d"; + CPPUNIT_ASSERT_EQUAL( buf.append( d ).toString(), foobazbard ); + CPPUNIT_ASSERT_EQUAL( buf.insert( 3, d ).toString(), foodbazbard ); + CPPUNIT_ASSERT( rtl_string_unittest_const_literal == false ); CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == false ); } |