1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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>
20 class Test
: public CppUnit::TestFixture
{
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() {
37 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), s
.getLength());
38 sal_Unicode
* p
= s
.appendUninitialized(5);
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);
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() {
56 sal_Unicode
* p
= s
.appendUninitialized(0);
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: */