bump product version to 5.0.4.1
[LibreOffice.git] / sal / qa / rtl / oustringbuffer / test_oustringbuffer_appenduninitialized.cxx
blob7530d6a32273e21361b2667375b564e738a4e25f
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/TestAssert.h>
13 #include <cppunit/TestFixture.h>
14 #include <cppunit/extensions/HelperMacros.h>
15 #include <rtl/ustrbuf.hxx>
16 #include <sal/types.h>
18 namespace {
20 class Test: public CppUnit::TestFixture {
21 private:
22 void testEmpty();
24 void testNonEmpty();
26 void testZero();
28 CPPUNIT_TEST_SUITE(Test);
29 CPPUNIT_TEST(testEmpty);
30 CPPUNIT_TEST(testNonEmpty);
31 CPPUNIT_TEST(testZero);
32 CPPUNIT_TEST_SUITE_END();
35 void Test::testEmpty() {
36 OUStringBuffer s;
37 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), s.getLength());
38 sal_Unicode * p = s.appendUninitialized(5);
39 CPPUNIT_ASSERT_EQUAL(
40 static_cast<void const *>(s.getStr()), static_cast<void const *>(p));
41 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), s.getLength());
44 void Test::testNonEmpty() {
45 OUStringBuffer s("ab");
46 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), s.getLength());
47 sal_Unicode * p = s.appendUninitialized(5);
48 CPPUNIT_ASSERT_EQUAL(
49 static_cast<void const *>(s.getStr() + 2),
50 static_cast<void const *>(p));
51 CPPUNIT_ASSERT_EQUAL(sal_Int32(7), s.getLength());
54 void Test::testZero() {
55 OUStringBuffer s;
56 sal_Unicode * p = s.appendUninitialized(0);
57 CPPUNIT_ASSERT_EQUAL(
58 static_cast<void const *>(s.getStr()), static_cast<void const *>(p));
59 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), s.getLength());
62 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
66 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */