[libsigcplusplus] test_signal: Test calls to signal_base::clear()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigcplusplus] test_signal: Test calls to signal_base::clear()
- Date: Mon, 17 Jul 2017 08:04:06 +0000 (UTC)
commit 8e78fb470996645767909556b4a1089492ffa380
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Mon Jul 17 10:00:07 2017 +0200
test_signal: Test calls to signal_base::clear()
Call it both during signal emission and otherwise. Bug 784550
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]