From 6ba8a2eab28cbe0967b360a09e1e9d7a7bb7bd26 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 4 Feb 2013 14:44:24 +0100 Subject: OK for boolean() to take true bool argument ...instead of sal_Bool; this would cause C4800 performance warnings with MSVC, but we disable them anyway. Also, added unit tests that are actually executed. Change-Id: Ib405132565918be72d93b3fc24180edcb6e565c7 --- sal/inc/rtl/string.hxx | 4 ++-- sal/inc/rtl/ustring.hxx | 4 ++-- sal/qa/rtl/strings/test_strings_valuex.cxx | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) (limited to 'sal') diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 9ed01e5824cb..a239768df777 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -1504,11 +1504,11 @@ public: If the sal_Bool is false, the string "false" is returned. This function can't be used for language specific conversion. - @param b a sal_Bool. + @param b a bool. @return a string with the string representation of the argument. @since LibreOffice 4.1 */ - static OString boolean( sal_Bool b ) SAL_THROW(()) + static OString boolean( bool b ) SAL_THROW(()) { sal_Char aBuf[RTL_STR_MAX_VALUEOFBOOLEAN]; rtl_String* pNewData = 0; diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 7cdbb4e22d90..25ed82b2b83d 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -2155,11 +2155,11 @@ public: If the sal_Bool is false, the string "false" is returned. This function can't be used for language specific conversion. - @param b a sal_Bool. + @param b a bool. @return a string with the string representation of the argument. @since LibreOffice 4.1 */ - static OUString boolean( sal_Bool b ) SAL_THROW(()) + static OUString boolean( bool b ) SAL_THROW(()) { sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFBOOLEAN]; rtl_uString* pNewData = 0; diff --git a/sal/qa/rtl/strings/test_strings_valuex.cxx b/sal/qa/rtl/strings/test_strings_valuex.cxx index cbd12c5ff94f..3ad4cd7a4b99 100644 --- a/sal/qa/rtl/strings/test_strings_valuex.cxx +++ b/sal/qa/rtl/strings/test_strings_valuex.cxx @@ -17,12 +17,16 @@ namespace test { namespace strings { class valueX : public CppUnit::TestFixture { public: + void testOBoolean(); + void testOUBoolean(); void testOUInt(); void testOInt(); void testOUFloat(); void testOFloat(); CPPUNIT_TEST_SUITE(valueX); + CPPUNIT_TEST(testOBoolean); + CPPUNIT_TEST(testOUBoolean); CPPUNIT_TEST(testOUInt); CPPUNIT_TEST(testOInt); CPPUNIT_TEST(testOUFloat); @@ -34,6 +38,26 @@ public: CPPUNIT_TEST_SUITE_REGISTRATION(test::strings::valueX); +namespace { + +template< typename T > +void testBoolean() { + CPPUNIT_ASSERT_EQUAL( T( "false" ), T::boolean( false ) ); + CPPUNIT_ASSERT_EQUAL( T( "false" ), T::boolean( sal_False ) ); + CPPUNIT_ASSERT_EQUAL( T( "true" ), T::boolean( true ) ); + CPPUNIT_ASSERT_EQUAL( T( "true" ), T::boolean( sal_True ) ); +} + +} + +void test::strings::valueX::testOBoolean() { + testBoolean(); +} + +void test::strings::valueX::testOUBoolean() { + testBoolean(); +} + template< typename T > void testInt() { CPPUNIT_ASSERT_EQUAL( T( "30039062" ), T::number( 30039062 )); -- cgit