[libsigcplusplus] test_mem_fun: Rearrange into individual test functions.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigcplusplus] test_mem_fun: Rearrange into individual test functions.
- Date: Fri, 1 Apr 2016 09:32:18 +0000 (UTC)
commit cba1d904afe85ea24d39608c0469592876ef68be
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 | 160 +++++++++++++++++++++++++++++--------------------
1 files changed, 95 insertions(+), 65 deletions(-)
---
diff --git a/tests/test_mem_fun.cc b/tests/test_mem_fun.cc
index 968fe24..1b32ae6 100644
--- a/tests/test_mem_fun.cc
+++ b/tests/test_mem_fun.cc
@@ -14,6 +14,8 @@
namespace
{
+
+TestUtilities* util = nullptr;
std::ostringstream result_stream;
struct test
@@ -50,88 +52,116 @@ struct test
} // end anonymous namespace
-int
-main(int argc, char* argv[])
+void test_non_const()
{
- auto util = TestUtilities::get_instance();
+ test t;
+ sigc::mem_fun (&test::foo)(t, 1);
+ util->check_result(result_stream, "test::foo(short 1)");
+}
- if (!util->check_command_args(argc, argv))
- return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+void 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_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_non_const_volatile()
+{
+ test t;
+ sigc::mem_fun (&test::foo_volatile)(t, 4);
+ util->check_result(result_stream, "test::foo_volatile(float 4)");
+}
+
+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)");
+}
+
+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)");
+}
- { /* test non-const */
- test t;
- sigc::mem_fun (&test::foo)(t, 1);
- 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)");
- }
- { /* 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)");
- }
- { /* test non-const volatile */
- test t;
- sigc::mem_fun (&test::foo_volatile)(t, 4);
- util->check_result(result_stream, "test::foo_volatile(float 4)");
- }
- { /* 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)");
- }
- { /* 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)");
- }
#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
- { /* test overloaded */
- test t;
- sigc::mem_fun<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_fun<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_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);
- 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)(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_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_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_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);
+ 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_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]