summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2019-09-26 11:56:21 +0200
committerMurray Cumming <murrayc@murrayc.com>2019-09-26 11:59:04 +0200
commit0136f43a7ad513e533853403ea169988e9c7e434 (patch)
tree4bef4827916b08b048ebd96f0eaa6e9cdd995774
parent138510d4002a0ee866016f462e6687454757b4e8 (diff)
downloadsigc++-0136f43a7ad513e533853403ea169988e9c7e434.tar.gz
tests: Add test_connection, to check copying
For now, this just confirms that we can now copy empty sigc::connection instances. (See the previous commit.)
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/Makefile.am2
-rwxr-xr-xtests/memleakcheck.sh2
-rw-r--r--tests/test_connection.cc45
5 files changed, 50 insertions, 1 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index ca60f86..276abe2 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -8,6 +8,7 @@
/test_bind_refptr
/test_bind_return
/test_compose
+/test_connection
/test_copy_invalid_slot
/test_cpp11_lambda
/test_custom
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index ab089eb..feb4eef 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -25,6 +25,7 @@ set (TEST_SOURCE_FILES
test_bind_refptr.cc
test_bind_return.cc
test_compose.cc
+ test_connection.cc
test_copy_invalid_slot.cc
test_cpp11_lambda.cc
test_custom.cc
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 114789f..735d76b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -32,6 +32,7 @@ check_PROGRAMS = \
test_bind_refptr \
test_bind_return \
test_compose \
+ test_connection \
test_copy_invalid_slot \
test_cpp11_lambda \
test_custom \
@@ -75,6 +76,7 @@ test_bind_ref_SOURCES = test_bind_ref.cc $(sigc_test_util)
test_bind_refptr_SOURCES = test_bind_refptr.cc $(sigc_test_util)
test_bind_return_SOURCES = test_bind_return.cc $(sigc_test_util)
test_compose_SOURCES = test_compose.cc $(sigc_test_util)
+test_connection_SOURCES = test_connection.cc $(sigc_test_util)
test_copy_invalid_slot_SOURCES = test_copy_invalid_slot.cc $(sigc_test_util)
test_cpp11_lambda_SOURCES = test_cpp11_lambda.cc $(sigc_test_util)
test_custom_SOURCES = test_custom.cc $(sigc_test_util)
diff --git a/tests/memleakcheck.sh b/tests/memleakcheck.sh
index 07a7311..4c8f4cd 100755
--- a/tests/memleakcheck.sh
+++ b/tests/memleakcheck.sh
@@ -5,7 +5,7 @@
# valgrind --leak-check=full .libs/lt-test_*
for testprog in test_accum_iter test_accumulated test_bind test_bind_as_slot \
- test_bind_ref test_bind_refptr test_bind_return test_compose \
+ test_bind_ref test_bind_refptr test_bind_return test_compose test_connection \
test_copy_invalid_slot test_cpp11_lambda test_custom test_disconnect \
test_disconnect_during_emit test_exception_catch test_hide \
test_limit_reference test_member_method_trait test_mem_fun test_ptr_fun \
diff --git a/tests/test_connection.cc b/tests/test_connection.cc
new file mode 100644
index 0000000..ec12765
--- /dev/null
+++ b/tests/test_connection.cc
@@ -0,0 +1,45 @@
+/* Copyright 2019, 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 <iostream>
+
+namespace
+{
+
+TestUtilities* util = nullptr;
+std::ostringstream result_stream;
+
+void
+test_connection_copy_empty()
+{
+ sigc::connection con1;
+
+ // Try to prevent the compiler from optimising away the copy.
+ std::cout << &con1 << std::endl;
+
+ sigc::connection con2(con1);
+
+ // Try to prevent the compiler from optimising away the copy.
+ std::cout << &con2 << std::endl;
+}
+
+} // 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_connection_copy_empty();
+
+ // See also test_disconnection.cc
+
+ return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
+}