summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-06-07 10:41:55 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-06-07 11:36:08 +0000
commitb5ad72bbfca85946e352b56d9d2ee5eb71cd2132 (patch)
tree21b442063df00352b56c6f4ff3b0bd0c3d95b22e /sal
parent7a11763823eef04e9602c7de3fff44415061d7cb (diff)
Replace VALID_CONVERSION macro with function
...to avoid bogus -Werror=unused-result from trunk GCC in the macro expansion. Change-Id: I227a0edfb22255c31d285609761dbefb4e50e09a Reviewed-on: https://gerrit.libreoffice.org/26004 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/qa/rtl/strings/test_oustring_stringliterals.cxx42
1 files changed, 32 insertions, 10 deletions
diff --git a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
index 825e7d84ad25..ff4300052f1e 100644
--- a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
+++ b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
@@ -14,6 +14,10 @@ extern bool rtl_string_unittest_invalid_conversion;
extern bool rtl_string_unittest_const_literal_function;
extern bool rtl_string_unittest_non_const_literal_function;
+#include <sal/config.h>
+
+#include <utility>
+
#include <sal/types.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
@@ -49,12 +53,20 @@ CPPUNIT_TEST_SUITE_END();
// reset the flag, evaluate the expression and return
// whether the string literal ctor was used (i.e. whether the conversion was valid)
-#define VALID_CONVERSION( expression ) \
- ( \
- rtl_string_unittest_invalid_conversion = false, \
- ( void ) rtl::OUString( expression ), \
- ( void ) rtl::OUStringBuffer( expression ), \
- !rtl_string_unittest_invalid_conversion )
+template<typename T> bool VALID_CONVERSION( T && expression )
+{
+ rtl_string_unittest_invalid_conversion = false;
+ ( void ) rtl::OUString( std::forward<T>(expression) );
+ ( void ) rtl::OUStringBuffer( std::forward<T>(expression) );
+ return !rtl_string_unittest_invalid_conversion;
+}
+template<typename T> bool VALID_CONVERSION_CALL( T f )
+{
+ rtl_string_unittest_invalid_conversion = false;
+ ( void ) rtl::OUString( f() );
+ ( void ) rtl::OUStringBuffer( f() );
+ return !rtl_string_unittest_invalid_conversion;
+}
void test::oustring::StringLiterals::checkCtors()
{
@@ -93,7 +105,8 @@ void test::oustring::StringLiterals::checkCtors()
void test::oustring::StringLiterals::testcall( const char str[] )
{
- CPPUNIT_ASSERT( !VALID_CONVERSION( rtl::OUString( str )));
+ CPPUNIT_ASSERT(
+ !VALID_CONVERSION_CALL([&str]() { return rtl::OUString(str); }));
}
void test::oustring::StringLiterals::checkUsage()
@@ -154,9 +167,18 @@ void test::oustring::StringLiterals::checkNonconstChar()
char bar[] = "bar";
const char consttest[] = "test";
const char constbar[] = "bar";
- CPPUNIT_ASSERT( !VALID_CONVERSION( rtl::OUString( "footest" ).replaceAll( test, bar )));
- CPPUNIT_ASSERT( !VALID_CONVERSION( rtl::OUString( "footest" ).replaceAll( consttest, bar )));
- CPPUNIT_ASSERT( !VALID_CONVERSION( rtl::OUString( "footest" ).replaceAll( test, constbar )));
+ CPPUNIT_ASSERT(
+ !VALID_CONVERSION_CALL(
+ [&test, &bar]() {
+ return rtl::OUString("footest").replaceAll(test, bar); }));
+ CPPUNIT_ASSERT(
+ !VALID_CONVERSION_CALL(
+ [&consttest, &bar]() {
+ return rtl::OUString("footest").replaceAll(consttest, bar); }));
+ CPPUNIT_ASSERT(
+ !VALID_CONVERSION(
+ [&test, &constbar]() {
+ return rtl::OUString("footest").replaceAll(test, constbar); }));
CPPUNIT_ASSERT( rtl::OUString( "foobar" ) == rtl::OUString( "footest" ).replaceAll( consttest, constbar ));
}