Mark some Calc slots as inactive in readonly mode
[LibreOffice.git] / sal / qa / rtl / strings / test_ostringbuffer.cxx
blob292e24310b7b140a2ef2b6652b8f9e3f8202c603
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 <string_view>
14 #include <cppunit/TestFixture.h>
15 #include <cppunit/TestAssert.h>
16 #include <cppunit/extensions/HelperMacros.h>
18 #include <rtl/strbuf.hxx>
19 #include <rtl/stringutils.hxx>
20 #include <sal/types.h>
22 namespace
24 class Test : public CppUnit::TestFixture
26 private:
27 void testStringView()
29 OStringBuffer b("foobar");
30 b = std::string_view("abc").substr(
31 0, 2); // avoid the string_view accidentally being NUL-terminated
32 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), b.getLength());
33 CPPUNIT_ASSERT_EQUAL('a', b.getStr()[0]);
34 CPPUNIT_ASSERT_EQUAL('b', b.getStr()[1]);
35 CPPUNIT_ASSERT_EQUAL('\0', b.getStr()[2]);
38 void testOStringChar()
40 OStringBuffer b("foobar");
41 b = OStringChar('a');
42 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), b.getLength());
43 CPPUNIT_ASSERT_EQUAL('a', b.getStr()[0]);
44 CPPUNIT_ASSERT_EQUAL('\0', b.getStr()[1]);
47 CPPUNIT_TEST_SUITE(Test);
48 CPPUNIT_TEST(testStringView);
49 CPPUNIT_TEST(testOStringChar);
50 CPPUNIT_TEST_SUITE_END();
54 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
56 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */