From 67f44c0202010ad149ee9e955fecd9ac057485f7 Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Tue, 2 Apr 2024 08:59:21 +0800 Subject: [PATCH] feat add sigslot test case --- CMakeLists.txt | 1 + src/sled/sigslot_test.cc | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/sled/sigslot_test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dc2421..734fbeb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -188,6 +188,7 @@ if(SLED_BUILD_TESTS) src/sled/utility/move_on_copy_test.cc) sled_add_test(NAME sled_symbolize_test SRCS src/sled/debugging/symbolize_test.cc NO_MAIN) + sled_add_test(NAME sled_sigslot_test SRCS src/sled/sigslot_test.cc) endif(SLED_BUILD_TESTS) if(SLED_BUILD_FUZZ) diff --git a/src/sled/sigslot_test.cc b/src/sled/sigslot_test.cc new file mode 100644 index 0000000..8efa501 --- /dev/null +++ b/src/sled/sigslot_test.cc @@ -0,0 +1,16 @@ +#include + +struct DeleteSelf : public sigslot::has_slots<> { + void DeleteThis() { + delete this; + } +}; + +TEST_SUITE("sigslot") { + TEST_CASE("delete this") { + DeleteSelf* d = new DeleteSelf(); + sigslot::signal0<> sig; + sig.connect(d, &DeleteSelf::DeleteThis); + sig.emit(); + } +}