Skip to content

Commit 8e78fb4

Browse files
committed
test_signal: Test calls to signal_base::clear()
Call it both during signal emission and otherwise. Bug 784550
1 parent 65edaa5 commit 8e78fb4

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/test_signal.cc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,35 @@ test_make_slot()
112112
util->check_result(result_stream, "foo(int 3) bar(float 3) foo(int 3) ");
113113
}
114114

115+
void
116+
test_clear_called_in_signal_handler()
117+
{
118+
sigc::signal<void()> sig;
119+
sig.connect([]() { result_stream << ", slot 1, "; });
120+
sig.connect([&sig]() { sig.clear(); result_stream << "slot 2, "; });
121+
sig.connect([]() { result_stream << "slot 3, "; });
122+
result_stream << sig.size();
123+
sig.emit();
124+
result_stream << sig.size();
125+
sig.emit();
126+
util->check_result(result_stream, "3, slot 1, slot 2, 0");
127+
}
128+
129+
void
130+
test_clear_called_outside_signal_handler()
131+
{
132+
sigc::signal<void()> sig;
133+
sig.connect([]() { result_stream << ", slot 1, "; });
134+
sig.connect([]() { result_stream << "slot 2, "; });
135+
sig.connect([]() { result_stream << "slot 3, "; });
136+
result_stream << sig.size();
137+
sig.emit();
138+
sig.clear();
139+
result_stream << sig.size();
140+
sig.emit();
141+
util->check_result(result_stream, "3, slot 1, slot 2, slot 3, 0");
142+
}
143+
115144
} // end anonymous namespace
116145

117146
int
@@ -127,6 +156,8 @@ main(int argc, char* argv[])
127156
test_auto_disconnection();
128157
test_reference();
129158
test_make_slot();
159+
test_clear_called_in_signal_handler();
160+
test_clear_called_outside_signal_handler();
130161

131162
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
132163
}

0 commit comments

Comments
 (0)