diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-09-20 11:34:35 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-09-20 11:34:35 +0200 |
commit | 95ee4cab864c0bafb23bc7d0e3ac25a0d91e22f8 (patch) | |
tree | 75cbe1c7e51d51912bd3fc034aec4767aeaf3a9d /sal/qa | |
parent | 7e965ee623a31392d86eb925acaf8ea664a33da7 (diff) |
Related cid#1371289: Work around missing OUStringBuffer move semantics
...by adding more assign op overloads instead
Change-Id: I2d2e1b7f19d1b57528707ed5a5cce94b5fa5c2d0
Diffstat (limited to 'sal/qa')
-rw-r--r-- | sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx new file mode 100644 index 000000000000..e2e6661e5bef --- /dev/null +++ b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_assign.cxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> + +#include <cppunit/TestFixture.h> +#include <cppunit/TestAssert.h> +#include <cppunit/extensions/HelperMacros.h> + +#include <rtl/ustrbuf.hxx> +#include <rtl/ustring.hxx> + +namespace { + +class Test: public CppUnit::TestFixture { +private: + void test() { + OUStringBuffer b1; + OUString s1("123456789012345"); + b1 = s1; + CPPUNIT_ASSERT_EQUAL(s1, b1.toString()); + CPPUNIT_ASSERT_EQUAL(16, b1.getCapacity()); + OUString s2("abc"); + b1 = s2; + CPPUNIT_ASSERT_EQUAL(s2, b1.toString()); + CPPUNIT_ASSERT_EQUAL(16, b1.getCapacity()); + OUString s3("1234567890123456"); + b1 = s3; + CPPUNIT_ASSERT_EQUAL(s3, b1.toString()); + CPPUNIT_ASSERT_EQUAL(32, b1.getCapacity()); + OUStringBuffer b2; + b2 = "123456789012345"; + CPPUNIT_ASSERT_EQUAL(s1, b2.toString()); + CPPUNIT_ASSERT_EQUAL(16, b2.getCapacity()); + b2 = "abc"; + CPPUNIT_ASSERT_EQUAL(s2, b2.toString()); + CPPUNIT_ASSERT_EQUAL(16, b2.getCapacity()); + b2 = "1234567890123456"; + CPPUNIT_ASSERT_EQUAL(s3, b2.toString()); + CPPUNIT_ASSERT_EQUAL(32, b2.getCapacity()); +#if HAVE_CXX11_UTF16_STRING_LITERAL \ + && (!defined SAL_W32 || defined __MINGW32__) + // sal_Unicode is still wchar_t not char16_t even for MSVC 2015 + OUStringBuffer b3; + b3 = u"123456789012345"; + CPPUNIT_ASSERT_EQUAL(s1, b3.toString()); + CPPUNIT_ASSERT_EQUAL(16, b3.getCapacity()); + b3 = u"abc"; + CPPUNIT_ASSERT_EQUAL(s2, b3.toString()); + CPPUNIT_ASSERT_EQUAL(16, b3.getCapacity()); + b3 = u"1234567890123456"; + CPPUNIT_ASSERT_EQUAL(s3, b3.toString()); + CPPUNIT_ASSERT_EQUAL(32, b3.getCapacity()); +#endif + OUStringBuffer b4; + b4 = OUStringLiteral("1") + "23456789012345"; + CPPUNIT_ASSERT_EQUAL(s1, b4.toString()); + CPPUNIT_ASSERT_EQUAL(16, b4.getCapacity()); + b4 = OUStringLiteral("a") + "bc"; + CPPUNIT_ASSERT_EQUAL(s2, b4.toString()); + CPPUNIT_ASSERT_EQUAL(16, b4.getCapacity()); + b4 = OUStringLiteral("1") + "234567890123456"; + CPPUNIT_ASSERT_EQUAL(s3, b4.toString()); + CPPUNIT_ASSERT_EQUAL(32, b4.getCapacity()); + } + + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(test); + CPPUNIT_TEST_SUITE_END(); +}; + +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |