diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2011-11-03 16:08:53 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2011-11-04 08:21:24 +0100 |
commit | fb17dce09e29c4518129587d347cc3787f74c396 (patch) | |
tree | 86c88a45ca5332ad315e6aa0d33a21d1ed0e2cf3 /sal | |
parent | 08488edd45b7b4fa6b255c4a3e5b882765e6fc13 (diff) |
Added OUStringBuffer::append(char) so that b.append(' ') does what one expects.
Diffstat (limited to 'sal')
-rw-r--r-- | sal/inc/rtl/ustrbuf.hxx | 18 | ||||
-rw-r--r-- | sal/qa/rtl/oustringbuffer/makefile.mk | 1 | ||||
-rw-r--r-- | sal/qa/rtl/oustringbuffer/test_oustringbuffer_appendchar.cxx | 63 |
3 files changed, 82 insertions, 0 deletions
diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx index 47569e5800b3..60bb750a1dc7 100644 --- a/sal/inc/rtl/ustrbuf.hxx +++ b/sal/inc/rtl/ustrbuf.hxx @@ -421,6 +421,24 @@ public: } /** + Appends the string representation of the ASCII <code>char</code> + argument to this string buffer. + + The argument is appended to the contents of this string buffer. + The length of this string buffer increases by <code>1</code>. + + @param ch an ASCII <code>char</code>. + @return this string buffer. + + @since LibreOffice 3.5 + */ + OUStringBuffer & append(char c) + { + OSL_ASSERT(static_cast< unsigned char >(c) <= 0x7F); + return append(sal_Unicode(c)); + } + + /** Appends the string representation of the <code>char</code> argument to this string buffer. diff --git a/sal/qa/rtl/oustringbuffer/makefile.mk b/sal/qa/rtl/oustringbuffer/makefile.mk index 80cff0885b75..5e729691b4fa 100644 --- a/sal/qa/rtl/oustringbuffer/makefile.mk +++ b/sal/qa/rtl/oustringbuffer/makefile.mk @@ -46,6 +46,7 @@ CFLAGSCXX += $(CPPUNIT_CFLAGS) SHL1TARGET := $(TARGET) SHL1OBJS := \ + $(SLO)$/test_oustringbuffer_appendchar.obj \ $(SLO)$/test_oustringbuffer_utf32.obj \ $(SLO)$/test_oustringbuffer_tostring.obj \ $(SLO)$/test_oustringbuffer_noadditional.obj diff --git a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_appendchar.cxx b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_appendchar.cxx new file mode 100644 index 000000000000..f936aecd96a1 --- /dev/null +++ b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_appendchar.cxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * [ Copyright (C) 2011 Stephan Bergmann, Red Hat <sbergman@redhat.com> (initial + * developer) ] + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include "precompiled_sal.hxx" +#include "sal/config.h" +#include "sal/precppunit.hxx" + +#include <cppunit/TestFixture.h> +#include <cppunit/TestAssert.h> +#include <cppunit/extensions/HelperMacros.h> +#include "rtl/ustrbuf.hxx" + +namespace test { namespace oustringbuffer { + +class AppendChar: public CppUnit::TestFixture { +private: + void testAppendChar(); + + CPPUNIT_TEST_SUITE(AppendChar); + CPPUNIT_TEST(testAppendChar); + CPPUNIT_TEST_SUITE_END(); +}; + +void AppendChar::testAppendChar() { + // Check that append('a') does not unexpectedly pick + // append(sal_Int32 i, sal_Int16 radix = 10): + rtl::OUStringBuffer s; + s.append('a'); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), s.getLength()); + CPPUNIT_ASSERT_EQUAL(sal_Unicode('a'), s[0]); +} + +} } + +CPPUNIT_TEST_SUITE_REGISTRATION(test::oustringbuffer::AppendChar); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |