Skip to content

Commit 0136f43

Browse files
committed
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.)
1 parent 138510d commit 0136f43

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

tests/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/test_bind_refptr
99
/test_bind_return
1010
/test_compose
11+
/test_connection
1112
/test_copy_invalid_slot
1213
/test_cpp11_lambda
1314
/test_custom

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ set (TEST_SOURCE_FILES
2525
test_bind_refptr.cc
2626
test_bind_return.cc
2727
test_compose.cc
28+
test_connection.cc
2829
test_copy_invalid_slot.cc
2930
test_cpp11_lambda.cc
3031
test_custom.cc

tests/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ check_PROGRAMS = \
3232
test_bind_refptr \
3333
test_bind_return \
3434
test_compose \
35+
test_connection \
3536
test_copy_invalid_slot \
3637
test_cpp11_lambda \
3738
test_custom \
@@ -75,6 +76,7 @@ test_bind_ref_SOURCES = test_bind_ref.cc $(sigc_test_util)
7576
test_bind_refptr_SOURCES = test_bind_refptr.cc $(sigc_test_util)
7677
test_bind_return_SOURCES = test_bind_return.cc $(sigc_test_util)
7778
test_compose_SOURCES = test_compose.cc $(sigc_test_util)
79+
test_connection_SOURCES = test_connection.cc $(sigc_test_util)
7880
test_copy_invalid_slot_SOURCES = test_copy_invalid_slot.cc $(sigc_test_util)
7981
test_cpp11_lambda_SOURCES = test_cpp11_lambda.cc $(sigc_test_util)
8082
test_custom_SOURCES = test_custom.cc $(sigc_test_util)

tests/memleakcheck.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# valgrind --leak-check=full .libs/lt-test_*
66

77
for testprog in test_accum_iter test_accumulated test_bind test_bind_as_slot \
8-
test_bind_ref test_bind_refptr test_bind_return test_compose \
8+
test_bind_ref test_bind_refptr test_bind_return test_compose test_connection \
99
test_copy_invalid_slot test_cpp11_lambda test_custom test_disconnect \
1010
test_disconnect_during_emit test_exception_catch test_hide \
1111
test_limit_reference test_member_method_trait test_mem_fun test_ptr_fun \

tests/test_connection.cc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* Copyright 2019, The libsigc++ Development Team
2+
* Assigned to public domain. Use as you wish without restriction.
3+
*/
4+
5+
#include "testutilities.h"
6+
#include <sigc++/trackable.h>
7+
#include <sigc++/signal.h>
8+
#include <iostream>
9+
10+
namespace
11+
{
12+
13+
TestUtilities* util = nullptr;
14+
std::ostringstream result_stream;
15+
16+
void
17+
test_connection_copy_empty()
18+
{
19+
sigc::connection con1;
20+
21+
// Try to prevent the compiler from optimising away the copy.
22+
std::cout << &con1 << std::endl;
23+
24+
sigc::connection con2(con1);
25+
26+
// Try to prevent the compiler from optimising away the copy.
27+
std::cout << &con2 << std::endl;
28+
}
29+
30+
} // end anonymous namespace
31+
32+
int
33+
main(int argc, char* argv[])
34+
{
35+
util = TestUtilities::get_instance();
36+
37+
if (!util->check_command_args(argc, argv))
38+
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
39+
40+
test_connection_copy_empty();
41+
42+
// See also test_disconnection.cc
43+
44+
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
45+
}

0 commit comments

Comments
 (0)