diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2017-07-17 10:00:07 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2017-07-17 10:00:07 +0200 |
commit | 8e78fb470996645767909556b4a1089492ffa380 (patch) | |
tree | 9df7e1a6ee6086a461bfdbe6c165c57fc4c965ff | |
parent | 65edaa5f036ad4a1d9ac5b0b8e8ed6e51524c096 (diff) | |
download | sigc++-8e78fb470996645767909556b4a1089492ffa380.tar.gz |
test_signal: Test calls to signal_base::clear()
Call it both during signal emission and otherwise. Bug 784550
-rw-r--r-- | tests/test_signal.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_signal.cc b/tests/test_signal.cc index b5728da..4ea7c11 100644 --- a/tests/test_signal.cc +++ b/tests/test_signal.cc @@ -112,6 +112,35 @@ test_make_slot() util->check_result(result_stream, "foo(int 3) bar(float 3) foo(int 3) "); } +void +test_clear_called_in_signal_handler() +{ + sigc::signal<void()> sig; + sig.connect([]() { result_stream << ", slot 1, "; }); + sig.connect([&sig]() { sig.clear(); result_stream << "slot 2, "; }); + sig.connect([]() { result_stream << "slot 3, "; }); + result_stream << sig.size(); + sig.emit(); + result_stream << sig.size(); + sig.emit(); + util->check_result(result_stream, "3, slot 1, slot 2, 0"); +} + +void +test_clear_called_outside_signal_handler() +{ + sigc::signal<void()> sig; + sig.connect([]() { result_stream << ", slot 1, "; }); + sig.connect([]() { result_stream << "slot 2, "; }); + sig.connect([]() { result_stream << "slot 3, "; }); + result_stream << sig.size(); + sig.emit(); + sig.clear(); + result_stream << sig.size(); + sig.emit(); + util->check_result(result_stream, "3, slot 1, slot 2, slot 3, 0"); +} + } // end anonymous namespace int @@ -127,6 +156,8 @@ main(int argc, char* argv[]) test_auto_disconnection(); test_reference(); test_make_slot(); + test_clear_called_in_signal_handler(); + test_clear_called_outside_signal_handler(); return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE; } |