[libsigc++2] Added test_signal_move.



commit 85ce9bcf95e8d1603eadded16451c329b4aad1ee
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Sep 1 16:24:36 2015 +0200

    Added test_signal_move.
    
    This seems to work.

 tests/Makefile.am         |    2 +
 tests/test_signal_move.cc |   50 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4f5a872..fd3f187 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -42,6 +42,7 @@ check_PROGRAMS = \
   test_retype \
   test_retype_return \
   test_signal \
+  test_signal_move \
   test_size \
   test_slot \
   test_slot_disconnect \
@@ -77,6 +78,7 @@ test_ptr_fun_SOURCES         = test_ptr_fun.cc $(sigc_test_util)
 test_retype_SOURCES          = test_retype.cc $(sigc_test_util)
 test_retype_return_SOURCES   = test_retype_return.cc $(sigc_test_util)
 test_signal_SOURCES          = test_signal.cc $(sigc_test_util)
+test_signal_move_SOURCES     = test_signal_move.cc $(sigc_test_util)
 test_size_SOURCES            = test_size.cc $(sigc_test_util)
 test_slot_SOURCES            = test_slot.cc $(sigc_test_util)
 test_slot_disconnect_SOURCES = test_slot_disconnect.cc $(sigc_test_util)
diff --git a/tests/test_signal_move.cc b/tests/test_signal_move.cc
new file mode 100644
index 0000000..db60b56
--- /dev/null
+++ b/tests/test_signal_move.cc
@@ -0,0 +1,50 @@
+// -*- c++ -*-
+/* Copyright 2015, The libsigc++ Development Team
+ *  Assigned to public domain.  Use as you wish without restriction.
+ */
+
+#include "testutilities.h"
+#include <sigc++/trackable.h>
+#include <sigc++/signal.h>
+#include <sigc++/functors/ptr_fun.h>
+#include <sigc++/functors/mem_fun.h>
+#include <string>
+#include <cstdlib>
+
+namespace
+{
+std::ostringstream result_stream;
+
+int foo(int i)
+{
+  result_stream << "foo(int " << i << ")";
+  return 1;
+}
+
+} // end anonymous namespace
+
+int main(int argc, char* argv[])
+{
+  auto util = TestUtilities::get_instance();
+
+  if (!util->check_command_args(argc, argv))
+    return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+
+  // signal
+  sigc::signal<int, int> sig;
+  sig.connect(sigc::ptr_fun(&foo));
+  sig(1);
+  util->check_result(result_stream, "foo(int 1)");
+
+  //Test the move constructor:
+  sigc::signal<int, int> sig2(std::move(sig));
+  sig2(2);
+  util->check_result(result_stream, "foo(int 2)");
+
+  //Test the move assignment operator:
+  sigc::signal<int, int> sig3 = std::move(sig2);
+  sig3(3);
+  util->check_result(result_stream, "foo(int 3)");
+
+  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]