File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -66,3 +66,31 @@ TEST_CASE( "signals can be move assigned", "[move_tests]" ) {
66
66
REQUIRE ( ss.str () == " " );
67
67
}
68
68
}
69
+
70
+ TEST_CASE (" Move assigning signals to with state" , " [move_tests" ) {
71
+ using output_signal = nod::signal<void (std::ostream&)>;
72
+ output_signal signal_1;
73
+ auto connection_1 = signal_1.connect (
74
+ [](std::ostream& out){
75
+ out << " 1" ;
76
+ });
77
+ output_signal signal_2;
78
+ auto connection_2 = signal_2.connect (
79
+ [](std::ostream& out){
80
+ out << " 2" ;
81
+ });
82
+
83
+ signal_1 = std::move (signal_2);
84
+
85
+ SECTION ( " The moved-to instance has disconnected it's original connection" ) {
86
+ REQUIRE (connection_1.connected () == false );
87
+ }
88
+ SECTION ( " The moved-from instance has moved not disconnected its original connection, it is now owned by the moved-to instance" ) {
89
+ REQUIRE (connection_2.connected () == true );
90
+ }
91
+ SECTION ( " Triggering the moved-to signal has expected output" ) {
92
+ std::stringstream ss;
93
+ signal_1 (ss);
94
+ REQUIRE (ss.str () == " 2" );
95
+ }
96
+ }
You can’t perform that action at this time.
0 commit comments