[libsigcplusplus/libsigc++-2-10] test_mem_fun: Rearrange into individual test functions.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigcplusplus/libsigc++-2-10] test_mem_fun: Rearrange into individual test functions.
- Date: Fri, 1 Apr 2016 09:37:18 +0000 (UTC)
commit 1675c09064e1ba2505b676effe6065ee2db3fb62
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Apr 1 11:24:21 2016 +0200
test_mem_fun: Rearrange into individual test functions.
tests/test_mem_fun.cc | 187 +++++++++++++++++++++++++------------------------
1 files changed, 96 insertions(+), 91 deletions(-)
---
diff --git a/tests/test_mem_fun.cc b/tests/test_mem_fun.cc
index 32e568b..1b32ae6 100644
--- a/tests/test_mem_fun.cc
+++ b/tests/test_mem_fun.cc
@@ -8,24 +8,21 @@
#include <sstream>
#include <cstdlib>
-//TODO: put something like #ifndef FORTE (some older version, I think) or AIX xlC... #else ... #endif around:
+// 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
{
+
+TestUtilities* util = nullptr;
std::ostringstream result_stream;
struct test
{
- void foo(short i1)
- {
- result_stream << "test::foo(short " << i1 << ')';
- }
+ void foo(short i1) { result_stream << "test::foo(short " << i1 << ')'; }
- void foo_const(int i1) const
- {
- result_stream << "test::foo_const(int " << i1 << ')';
- }
+ void foo_const(int i1) const { result_stream << "test::foo_const(int " << i1 << ')'; }
void foo_volatile(float i1) volatile
{
@@ -37,10 +34,7 @@ struct test
result_stream << "test::foo_const_volatile(double " << i1 << ')';
}
- void foo_overloaded(char i1)
- {
- result_stream << "test::foo_overloaded(char " << int(i1) << ')';
- }
+ void foo_overloaded(char i1) { result_stream << "test::foo_overloaded(char " << int(i1) << ')'; }
#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
void foo_overloaded(short i1)
@@ -58,105 +52,116 @@ struct test
} // end anonymous namespace
-int main(int argc, char* argv[])
+void test_non_const()
{
- auto util = TestUtilities::get_instance();
-
- if (!util->check_command_args(argc, argv))
- return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
-
- { /* test non-const */
- test t;
- sigc::mem_fun(&test::foo)(t, 1); // on reference
- util->check_result(result_stream, "test::foo(short 1)");
+ test t;
+ sigc::mem_fun (&test::foo)(t, 1);
+ util->check_result(result_stream, "test::foo(short 1)");
+}
- sigc::mem_fun(&test::foo)(&t, 1); // on pointer
- util->check_result(result_stream, "test::foo(short 1)");
- }
- { /* test const */
- test t;
- sigc::mem_fun(&test::foo_const)(t, 2);
- util->check_result(result_stream, "test::foo_const(int 2)");
+void test_const()
+{
+ test t;
+ sigc::mem_fun (&test::foo_const)(t, 2);
+ util->check_result(result_stream, "test::foo_const(int 2)");
+}
- sigc::mem_fun(&test::foo_const)(&t, 2);
- util->check_result(result_stream, "test::foo_const(int 2)");
- }
- { /* test const with const object */
- const auto t = test();
- sigc::mem_fun(&test::foo_const)(t, 3);
- util->check_result(result_stream, "test::foo_const(int 3)");
+void test_const_with_const_object()
+{
+ const auto t = test();
+ sigc::mem_fun (&test::foo_const)(t, 3);
+ util->check_result(result_stream, "test::foo_const(int 3)");
+}
- sigc::mem_fun(&test::foo_const)(&t, 3);
- util->check_result(result_stream, "test::foo_const(int 3)");
- }
- { /* test non-const volatile */
- test t;
- sigc::mem_fun(&test::foo_volatile)(t, 4); // on reference
- util->check_result(result_stream, "test::foo_volatile(float 4)");
+void test_non_const_volatile()
+{
+ test t;
+ sigc::mem_fun (&test::foo_volatile)(t, 4);
+ util->check_result(result_stream, "test::foo_volatile(float 4)");
+}
- sigc::mem_fun(&test::foo_volatile)(&t, 4); // on pointer
- util->check_result(result_stream, "test::foo_volatile(float 4)");
- }
- { /* test const volatile */
- test t;
- sigc::mem_fun(&test::foo_const_volatile)(t, 5); // on reference
- util->check_result(result_stream, "test::foo_const_volatile(double 5)");
+void test_const_volatile()
+{
+ test t;
+ sigc::mem_fun (&test::foo_const_volatile)(t, 5);
+ util->check_result(result_stream, "test::foo_const_volatile(double 5)");
+}
- sigc::mem_fun(&test::foo_const_volatile)(&t, 5); // on pointer
- util->check_result(result_stream, "test::foo_const_volatile(double 5)");
- }
- { /* test const volatile with const object */
- const auto t = test();
- sigc::mem_fun(&test::foo_const_volatile)(t, 6); // on reference
- util->check_result(result_stream, "test::foo_const_volatile(double 6)");
+void test_const_volatile_with_const_object()
+{
+ const auto t = test();
+ sigc::mem_fun (&test::foo_const_volatile)(t, 6);
+ util->check_result(result_stream, "test::foo_const_volatile(double 6)");
+}
- sigc::mem_fun(&test::foo_const_volatile)(&t, 6); // on pointer
- util->check_result(result_stream, "test::foo_const_volatile(double 6)");
- }
#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
- { /* test overloaded */
- test t;
- sigc::mem_fun1<char>(&test::foo_overloaded)(&t, 7);
- util->check_result(result_stream, "test::foo_overloaded(char 7)");
+void test_overloaded()
+{
+ test t;
+ sigc::mem_fun<char> (&test::foo_overloaded)(t, 7);
+ util->check_result(result_stream, "test::foo_overloaded(char 7)");
- sigc::mem_fun1<short>(&test::foo_overloaded)(&t, 7);
- util->check_result(result_stream, "test::foo_overloaded(short 7)");
+ sigc::mem_fun<short> (&test::foo_overloaded)(t, 7);
+ util->check_result(result_stream, "test::foo_overloaded(short 7)");
- //sigc::mem_fun1(&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_fun2(&test::foo_overloaded)(&t, 7, 8);
- util->check_result(result_stream, "test::foo_overloaded(int 7, int 8)");
- }
+ sigc::mem_fun (&test::foo_overloaded)(t, 7, 8);
+ util->check_result(result_stream, "test::foo_overloaded(int 7, int 8)");
+}
#endif
- { /* test bound */
- test t;
- sigc::mem_fun(t, &test::foo)(9);
- util->check_result(result_stream, "test::foo(short 9)");
- sigc::mem_fun(&t, &test::foo)(9);
- util->check_result(result_stream, "test::foo(short 9)");
+void test_bound()
+{
+ test t;
+ sigc::mem_fun(t, &test::foo)(9);
+ util->check_result(result_stream, "test::foo(short 9)");
- sigc::mem_fun(t, &test::foo_const)(9);
- util->check_result(result_stream, "test::foo_const(int 9)");
+ sigc::mem_fun(t, &test::foo)(9);
+ util->check_result(result_stream, "test::foo(short 9)");
- sigc::mem_fun(&t, &test::foo_const)(9);
- util->check_result(result_stream, "test::foo_const(int 9)");
+ sigc::mem_fun(t, &test::foo_const)(9);
+ util->check_result(result_stream, "test::foo_const(int 9)");
- sigc::mem_fun(t, &test::foo_volatile)(9);
- util->check_result(result_stream, "test::foo_volatile(float 9)");
+ sigc::mem_fun(t, &test::foo_const)(9);
+ util->check_result(result_stream, "test::foo_const(int 9)");
- sigc::mem_fun(&t, &test::foo_volatile)(9);
- util->check_result(result_stream, "test::foo_volatile(float 9)");
+ sigc::mem_fun(t, &test::foo_volatile)(9);
+ util->check_result(result_stream, "test::foo_volatile(float 9)");
+
+ 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_fun2(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);
+ util->check_result(result_stream, "test::foo_overloaded(int 9, int 10)");
- sigc::mem_fun2(&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);
+ util->check_result(result_stream, "test::foo_overloaded(int 9, int 10)");
#endif
- }
+}
+
+int
+main(int argc, char* argv[])
+{
+ util = TestUtilities::get_instance();
+
+ if (!util->check_command_args(argc, argv))
+ return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+ test_non_const();
+ test_const();
+ test_const_with_const_object();
+ test_non_const_volatile();
+ test_const_volatile();
+ test_const_volatile_with_const_object();
+
+#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
+ test_overload();
+#endif
+
+ test_bound();
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]