[libsigcplusplus/libsigc++-2-8] test_slot(): Restructure this.



commit 0d64fd36d31ed33ef198227e1c6a6d51d8f68763
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Mar 11 10:13:06 2016 +0100

    test_slot(): Restructure this.
    
    To make it clearer and to keep the small tests more self-contained and
    separate.

 tests/test_slot.cc |   43 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 34 insertions(+), 9 deletions(-)
---
diff --git a/tests/test_slot.cc b/tests/test_slot.cc
index 07b3580..49c0226 100644
--- a/tests/test_slot.cc
+++ b/tests/test_slot.cc
@@ -14,6 +14,8 @@
 
 namespace
 {
+
+TestUtilities* util = nullptr;
 std::ostringstream result_stream;
 
 class foo
@@ -36,15 +38,8 @@ public:
   }
 };
 
-} // end anonymous namespace
-
-int main(int argc, char* argv[])
+void test_simple()
 {
-  auto util = TestUtilities::get_instance();
-
-  if (!util->check_command_args(argc, argv))
-    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
-
   // simple test
   sigc::slot<void,int> s1 = foo();
   s1(1);
@@ -53,32 +48,62 @@ int main(int argc, char* argv[])
   s1 = foo();
   s1(2);
   util->check_result(result_stream, "foo(int 2)");
+}
 
+void test_implicit_conversion()
+{
   // test implicit conversion
   sigc::slot<void,char> s2 = foo();
   s2(3);
   util->check_result(result_stream, "foo(int 3)");
+}
 
+void test_reference()
+{
   // test reference
   sigc::slot<void,std::string&> sl1 = foo();
   std::string str("guest book");
   sl1(str);
   result_stream << str;
   util->check_result(result_stream, "foo(string 'guest book') foo was here");
+}
 
+void test_operator_equals()
+{
   // test operator=
-  str = "guest book";
+  std::string str = "guest book";
+  sigc::slot<void,std::string&> sl1 = foo();
   sigc::slot<void,std::string&> sl2;
   sl2 = sl1;
   sl1 = sl2;
   sl1(str);
   result_stream << str;
   util->check_result(result_stream, "foo(string 'guest book') foo was here");
+}
 
+void test_copy_ctor()
+{
   // test copy ctor
+  sigc::slot<void,int> s1 = foo();
   sigc::slot<void,int> s1_clone(s1);
   s1_clone(4);
   util->check_result(result_stream, "foo(int 4)");
+}
+
+} // end anonymous namespace
+
+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_simple();
+  test_implicit_conversion();
+  test_reference();
+  test_operator_equals();
+  test_copy_ctor();
 
   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]