[libsigcplusplus] test_functor_trait: Rearange to make tests self-contained.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigcplusplus] test_functor_trait: Rearange to make tests self-contained.
- Date: Fri, 15 Apr 2016 08:03:14 +0000 (UTC)
commit d4a74008745a14997e7a39dee5ff85a552da33c2
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Apr 15 09:56:21 2016 +0200
test_functor_trait: Rearange to make tests self-contained.
I guess this should really be called test_visit_each_type.
tests/test_functor_trait.cc | 39 ++++++++++++++++++++++++++++-----------
1 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/tests/test_functor_trait.cc b/tests/test_functor_trait.cc
index fe1cf6d..6d1fc9c 100644
--- a/tests/test_functor_trait.cc
+++ b/tests/test_functor_trait.cc
@@ -13,6 +13,8 @@
namespace
{
+
+TestUtilities* util = nullptr;
std::ostringstream result_stream;
class trackable
@@ -66,32 +68,47 @@ bar(int)
} // end anonymous namespace
-int
-main(int argc, char* argv[])
+void test_hit_all_targets()
{
- auto util = TestUtilities::get_instance();
-
- if (!util->check_command_args(argc, argv))
- return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
-
int i = 1;
- int j = 2;
- int k = 3;
A a;
result_stream << "hit all targets: ";
sigc::visit_each(
print(), sigc::compose(sigc::bind(sigc::ptr_fun(&foo), std::ref(a), i), sigc::ptr_fun(&bar)));
util->check_result(result_stream, "hit all targets: other trackable int: 1 other ");
+}
+void test_hit_all_ints()
+{
+ int i = 2;
+ A a;
result_stream << "hit all ints: ";
sigc::visit_each_type<int>(
- print(), sigc::compose(sigc::bind(sigc::ptr_fun(&foo), std::ref(a), j), sigc::ptr_fun(&bar)));
+ print(), sigc::compose(sigc::bind(sigc::ptr_fun(&foo), std::ref(a), i), sigc::ptr_fun(&bar)));
util->check_result(result_stream, "hit all ints: int: 2 ");
+}
+void test_hit_all_trackable()
+{
+ int i = 3;
+ A a;
result_stream << "hit all trackable: ";
sigc::visit_each_type<trackable>(
- print(), sigc::compose(sigc::bind(sigc::ptr_fun(&foo), std::ref(a), k), sigc::ptr_fun(&bar)));
+ print(), sigc::compose(sigc::bind(sigc::ptr_fun(&foo), std::ref(a), i), sigc::ptr_fun(&bar)));
util->check_result(result_stream, "hit all trackable: trackable ");
+}
+
+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_hit_all_targets();
+ test_hit_all_ints();
+ test_hit_all_trackable();
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]