Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sal / qa / rtl / oustringbuffer / test_oustringbuffer_assign.cxx
blob0d9cd2b8208363b1640fc46328989f354c09c2ec
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/config.h>
12 #include <cppunit/TestFixture.h>
13 #include <cppunit/TestAssert.h>
14 #include <cppunit/extensions/HelperMacros.h>
16 #include <rtl/ustrbuf.hxx>
17 #include <rtl/ustring.hxx>
19 namespace {
21 class Test: public CppUnit::TestFixture {
22 private:
23 void test() {
24 OUStringBuffer b1;
25 OUString s1("123456789012345");
26 b1 = s1;
27 CPPUNIT_ASSERT_EQUAL(s1, b1.toString());
28 CPPUNIT_ASSERT_EQUAL(sal_Int32(16), b1.getCapacity());
29 OUString s2("abc");
30 b1 = s2;
31 CPPUNIT_ASSERT_EQUAL(s2, b1.toString());
32 CPPUNIT_ASSERT_EQUAL(sal_Int32(16), b1.getCapacity());
33 OUString s3("1234567890123456");
34 b1 = s3;
35 CPPUNIT_ASSERT_EQUAL(s3, b1.toString());
36 CPPUNIT_ASSERT_EQUAL(sal_Int32(32), b1.getCapacity());
37 OUStringBuffer b2;
38 b2 = "123456789012345";
39 CPPUNIT_ASSERT_EQUAL(s1, b2.toString());
40 CPPUNIT_ASSERT_EQUAL(sal_Int32(16), b2.getCapacity());
41 b2 = "abc";
42 CPPUNIT_ASSERT_EQUAL(s2, b2.toString());
43 CPPUNIT_ASSERT_EQUAL(sal_Int32(16), b2.getCapacity());
44 b2 = "1234567890123456";
45 CPPUNIT_ASSERT_EQUAL(s3, b2.toString());
46 CPPUNIT_ASSERT_EQUAL(sal_Int32(32), b2.getCapacity());
47 OUStringBuffer b3;
48 b3 = u"123456789012345";
49 CPPUNIT_ASSERT_EQUAL(s1, b3.toString());
50 CPPUNIT_ASSERT_EQUAL(sal_Int32(16), b3.getCapacity());
51 b3 = u"abc";
52 CPPUNIT_ASSERT_EQUAL(s2, b3.toString());
53 CPPUNIT_ASSERT_EQUAL(sal_Int32(16), b3.getCapacity());
54 b3 = u"1234567890123456";
55 CPPUNIT_ASSERT_EQUAL(s3, b3.toString());
56 CPPUNIT_ASSERT_EQUAL(sal_Int32(32), b3.getCapacity());
57 OUStringBuffer b4;
58 b4 = OUStringLiteral("1") + "23456789012345";
59 CPPUNIT_ASSERT_EQUAL(s1, b4.toString());
60 CPPUNIT_ASSERT_EQUAL(sal_Int32(16), b4.getCapacity());
61 b4 = OUStringLiteral("a") + "bc";
62 CPPUNIT_ASSERT_EQUAL(s2, b4.toString());
63 CPPUNIT_ASSERT_EQUAL(sal_Int32(16), b4.getCapacity());
64 b4 = OUStringLiteral("1") + "234567890123456";
65 CPPUNIT_ASSERT_EQUAL(s3, b4.toString());
66 CPPUNIT_ASSERT_EQUAL(sal_Int32(32), b4.getCapacity());
69 CPPUNIT_TEST_SUITE(Test);
70 CPPUNIT_TEST(test);
71 CPPUNIT_TEST_SUITE_END();
76 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */