[libsigc++2] Added test_slot_move
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigc++2] Added test_slot_move
- Date: Tue, 1 Sep 2015 14:17:52 +0000 (UTC)
commit db579ba760d05bc7711db0fa0d6cb8b2b5d5048a
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Sep 1 16:17:24 2015 +0200
Added test_slot_move
This seems to do what it should, acting much like regular slot copying.
tests/Makefile.am | 2 +
tests/test_slot_move.cc | 66 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1167e83..4f5a872 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -45,6 +45,7 @@ check_PROGRAMS = \
test_size \
test_slot \
test_slot_disconnect \
+ test_slot_move \
test_trackable \
test_trackable_move \
test_track_obj \
@@ -79,6 +80,7 @@ test_signal_SOURCES = test_signal.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)
+test_slot_move_SOURCES = test_slot_move.cc $(sigc_test_util)
test_trackable_SOURCES = test_trackable.cc $(sigc_test_util)
test_trackable_move_SOURCES = test_trackable_move.cc $(sigc_test_util)
test_track_obj_SOURCES = test_track_obj.cc $(sigc_test_util)
diff --git a/tests/test_slot_move.cc b/tests/test_slot_move.cc
new file mode 100644
index 0000000..62896b9
--- /dev/null
+++ b/tests/test_slot_move.cc
@@ -0,0 +1,66 @@
+// -*- c++ -*-
+/* Copyright 2015, The libsigc++ Development Team
+ * Assigned to public domain. Use as you wish without restriction.
+ */
+
+#include "testutilities.h"
+#include <sigc++/functors/slot.h>
+#include <sstream>
+#include <string>
+#include <cstdlib>
+
+//The Tru64 compiler seems to need this to avoid an unresolved symbol
+//See bug #161503
+#include <new>
+SIGC_USING_STD(new)
+
+namespace
+{
+std::ostringstream result_stream;
+
+class foo
+{
+public:
+ void operator()(int i)
+ {
+ result_stream << "foo(int " << i << ")";
+ }
+
+ void operator()(std::string& str)
+ {
+ result_stream << "foo(string '" << str << "') ";
+ str="foo was here";
+ }
+
+ void operator()(int, int)
+ {
+ result_stream << "foo(int, int)";
+ }
+};
+
+} // 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;
+
+ // simple test
+ sigc::slot<void,int> s1 = foo();
+ s1(1);
+ util->check_result(result_stream, "foo(int 1)");
+
+ // test move constructor:
+ sigc::slot<void,int> s2(std::move(s1));
+ s2(2);
+ util->check_result(result_stream, "foo(int 2)");
+
+ // test move assignment:
+ sigc::slot<void,int> s3 = std::move(s2);
+ s3(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]