From 56927e5eb059bf57eebf92690baa03e4aacb3155 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 27 Oct 2019 16:59:10 +0100 Subject: test_mem_fun(): Re-enable tests of overloaded functions But, as with test_ptr_fun(), we need to specify the types. The compiler doesn't seem to be able to figure it out based on the values passed. --- tests/test_mem_fun.cc | 31 ++++++++----------------------- tests/test_ptr_fun.cc | 3 ++- 2 files changed, 10 insertions(+), 24 deletions(-) (limited to 'tests') diff --git a/tests/test_mem_fun.cc b/tests/test_mem_fun.cc index dc21937..ee344af 100644 --- a/tests/test_mem_fun.cc +++ b/tests/test_mem_fun.cc @@ -5,10 +5,6 @@ #include "testutilities.h" #include -// TODO: put something like #ifndef FORTE (some older version, I think) or AIX xlC... #else ... -// #endif around: -#define ENABLE_TEST_OF_OVERLOADED_FUNCTIONS 0 - namespace { @@ -33,12 +29,10 @@ struct test void foo_overloaded(char i1) { result_stream << "test::foo_overloaded(char " << int(i1) << ')'; } -#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS void foo_overloaded(short i1) { result_stream << "test::foo_overloaded(short " << (int)i1 << ')'; } -#endif double foo_overloaded(int i1, int i2) { @@ -97,24 +91,22 @@ test_const_volatile_with_const_object() util->check_result(result_stream, "test::foo_const_volatile(double 6)"); } -#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS void test_overloaded() { test t; - sigc::mem_fun (&test::foo_overloaded)(t, 7); + + // We need to specify the types when using overloaded functions. + + sigc::mem_fun (&test::foo_overloaded)(t, 7); util->check_result(result_stream, "test::foo_overloaded(char 7)"); - sigc::mem_fun (&test::foo_overloaded)(t, 7); + sigc::mem_fun (&test::foo_overloaded)(t, 7); util->check_result(result_stream, "test::foo_overloaded(short 7)"); - // sigc::mem_fun(&test::foo_overloaded)(t, 7); - // util->check_result(result_stream, "test::foo_overloaded(short 7)"); - - sigc::mem_fun (&test::foo_overloaded)(t, 7, 8); + sigc::mem_fun (&test::foo_overloaded)(t, 7, 8); util->check_result(result_stream, "test::foo_overloaded(int 7, int 8)"); } -#endif void test_bound() @@ -138,13 +130,8 @@ test_bound() sigc::mem_fun(t, &test::foo_volatile)(9); util->check_result(result_stream, "test::foo_volatile(float 9)"); -#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS - sigc::mem_fun(t, &test::foo_overloaded)(9, 10); - util->check_result(result_stream, "test::foo_overloaded(int 9, int 10)"); - - sigc::mem_fun(t, &test::foo_overloaded)(9, 10); + sigc::mem_fun(t, &test::foo_overloaded)(9, 10); util->check_result(result_stream, "test::foo_overloaded(int 9, int 10)"); -#endif } class TestAutoDisconnect : public sigc::trackable @@ -188,9 +175,7 @@ main(int argc, char* argv[]) test_const_volatile(); test_const_volatile_with_const_object(); -#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS - test_overload(); -#endif + test_overloaded(); test_bound(); diff --git a/tests/test_ptr_fun.cc b/tests/test_ptr_fun.cc index b105389..6c29437 100644 --- a/tests/test_ptr_fun.cc +++ b/tests/test_ptr_fun.cc @@ -34,7 +34,8 @@ bar(char i1) // Note: This doesn't work with some older versions of g++, // even when we specify the return type. // Hopefully those g++ versions are old enough now. -void bar(float i1) +void +bar(float i1) { result_stream << "bar(float " << i1 << ")"; } -- cgit v1.2.1