summaryrefslogtreecommitdiff
path: root/sal/qa/rtl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-12-04 19:58:11 +0100
committerLuboš Luňák <l.lunak@suse.cz>2012-12-06 13:35:17 +0100
commit88c00598b2a0bae1bdfe88d4300afec2512183d8 (patch)
treec456c86afc1e712ecf93b7f96ab2417aa9e207ac /sal/qa/rtl
parentb88a26f02276ec2e98287cd2e5f2abea1ea9e949 (diff)
support for fast string operator+ in operator+=/append
Not much point in building a string instance that will be copied elsewhere immediatelly. Change-Id: I38b7d3696f2c619e6424eb3959b00cd2c7738c47
Diffstat (limited to 'sal/qa/rtl')
-rw-r--r--sal/qa/rtl/strings/test_ostring_concat.cxx19
-rw-r--r--sal/qa/rtl/strings/test_oustring_concat.cxx18
2 files changed, 31 insertions, 6 deletions
diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx b/sal/qa/rtl/strings/test_ostring_concat.cxx
index c3a422a51f5f..4c0630c56351 100644
--- a/sal/qa/rtl/strings/test_ostring_concat.cxx
+++ b/sal/qa/rtl/strings/test_ostring_concat.cxx
@@ -12,6 +12,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <rtl/string.hxx>
+#include <rtl/strbuf.hxx>
#include <typeinfo>
@@ -32,12 +33,14 @@ namespace test { namespace ostring {
class StringConcat : public CppUnit::TestFixture
{
private:
- void check();
+ void checkConcat();
void checkEnsureCapacity();
+ void checkAppend();
CPPUNIT_TEST_SUITE(StringConcat);
-CPPUNIT_TEST(check);
+CPPUNIT_TEST(checkConcat);
CPPUNIT_TEST(checkEnsureCapacity);
+CPPUNIT_TEST(checkAppend);
CPPUNIT_TEST_SUITE_END();
};
@@ -46,7 +49,7 @@ CPPUNIT_TEST_SUITE_END();
#else
#define TYPES_ASSERT_EQUAL( a, b )
#endif
-void test::ostring::StringConcat::check()
+void test::ostring::StringConcat::checkConcat()
{
// All the extra () are to protect commas againsts being treated as separators of macro arguments.
CPPUNIT_ASSERT_EQUAL( OString(), OString(OString() + OString()) );
@@ -113,6 +116,16 @@ void test::ostring::StringConcat::checkEnsureCapacity()
rtl_string_release( oldStr );
}
+void test::ostring::StringConcat::checkAppend()
+{
+ OString str( "foo" );
+ str += OStringLiteral( "bar" ) + "baz";
+ CPPUNIT_ASSERT_EQUAL( OString( "foobarbaz" ), str );
+ OStringBuffer buf( "foo" );
+ buf.append( OStringLiteral( "bar" ) + "baz" );
+ CPPUNIT_ASSERT_EQUAL( OString( "foobarbaz" ), buf.makeStringAndClear());
+}
+
}} // namespace
CPPUNIT_TEST_SUITE_REGISTRATION(test::ostring::StringConcat);
diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx b/sal/qa/rtl/strings/test_oustring_concat.cxx
index 108b166c6de2..8d98232a71a2 100644
--- a/sal/qa/rtl/strings/test_oustring_concat.cxx
+++ b/sal/qa/rtl/strings/test_oustring_concat.cxx
@@ -12,6 +12,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
#include <typeinfo>
@@ -32,12 +33,14 @@ namespace test { namespace oustring {
class StringConcat : public CppUnit::TestFixture
{
private:
- void check();
+ void checkConcat();
void checkEnsureCapacity();
+ void checkAppend();
CPPUNIT_TEST_SUITE(StringConcat);
-CPPUNIT_TEST(check);
+CPPUNIT_TEST(checkConcat);
CPPUNIT_TEST(checkEnsureCapacity);
+CPPUNIT_TEST(checkAppend);
CPPUNIT_TEST_SUITE_END();
};
@@ -46,7 +49,7 @@ CPPUNIT_TEST_SUITE_END();
#else
#define TYPES_ASSERT_EQUAL( a, b )
#endif
-void test::oustring::StringConcat::check()
+void test::oustring::StringConcat::checkConcat()
{
// All the extra () are to protect commas againsts being treated as separators of macro arguments.
CPPUNIT_ASSERT_EQUAL( OUString(), OUString(OUString() + OUString()) );
@@ -105,6 +108,15 @@ void test::oustring::StringConcat::checkEnsureCapacity()
rtl_uString_release( oldStr );
}
+void test::oustring::StringConcat::checkAppend()
+{
+ OUString str( "foo" );
+ str += OUStringLiteral( "bar" ) + "baz";
+ CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), str );
+ OUStringBuffer buf( "foo" );
+ buf.append( OUStringLiteral( "bar" ) + "baz" );
+ CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), buf.makeStringAndClear());
+}
}} // namespace