[libsigcplusplus/libsigc++-2-10] test_signal: Test calls to signal_base::clear()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigcplusplus/libsigc++-2-10] test_signal: Test calls to signal_base::clear()
- Date: Mon, 17 Jul 2017 08:22:55 +0000 (UTC)
commit 334079bc7d0cd67c2f4c11608c378213d1638132
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Mon Jul 17 10:18:29 2017 +0200
test_signal: Test calls to signal_base::clear()
Call it both during signal emission and otherwise. Bug 784550
tests/test_signal.cc | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_signal.cc b/tests/test_signal.cc
index bdd50dc..801e0bd 100644
--- a/tests/test_signal.cc
+++ b/tests/test_signal.cc
@@ -120,6 +120,33 @@ void test_std_function_style_syntax()
util->check_result(result_stream, "foo(int 1) ");
}
+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 main(int argc, char* argv[])
@@ -135,6 +162,8 @@ int main(int argc, char* argv[])
test_reference();
test_make_slot();
test_std_function_style_syntax();
+ 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]