aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2024-01-01 22:20:21 +0800
committercrupest <crupest@outlook.com>2024-01-18 21:12:28 +0800
commitdf799bf394fa63dc9f39a5b09fe21c16b1cc8a57 (patch)
treec9efa5b7a53545e2e1b7a9dff765817208911a7a /test
parentf79fc16b29a32c21461490a6482eada7baa9d7f8 (diff)
downloadcru-df799bf394fa63dc9f39a5b09fe21c16b1cc8a57.tar.gz
cru-df799bf394fa63dc9f39a5b09fe21c16b1cc8a57.tar.bz2
cru-df799bf394fa63dc9f39a5b09fe21c16b1cc8a57.zip
NEED TEST: fix compile errors of Event2 and create init test.
Diffstat (limited to 'test')
-rw-r--r--test/common/CMakeLists.txt1
-rw-r--r--test/common/Event2Test.cpp19
2 files changed, 20 insertions, 0 deletions
diff --git a/test/common/CMakeLists.txt b/test/common/CMakeLists.txt
index 602af819..f2fda47d 100644
--- a/test/common/CMakeLists.txt
+++ b/test/common/CMakeLists.txt
@@ -1,4 +1,5 @@
add_executable(CruBaseTest
+ Event2Test.cpp
HandlerRegistryTest.cpp
PropertyTreeTest.cpp
SelfResolvableTest.cpp
diff --git a/test/common/Event2Test.cpp b/test/common/Event2Test.cpp
new file mode 100644
index 00000000..f63a5347
--- /dev/null
+++ b/test/common/Event2Test.cpp
@@ -0,0 +1,19 @@
+#include "cru/common/Event2.h"
+
+#include <catch2/catch_test_macros.hpp>
+
+using cru::Event2;
+
+TEST_CASE("Event2 handlers should work.", "[event2]") {
+ Event2 event;
+
+ int counter = 0;
+
+ auto handler = [&counter] { counter++; };
+
+ event.AddHandler(handler);
+
+ event.Raise();
+
+ REQUIRE(counter == 1);
+}