From 9760767f112e67718ba5dc1af20ce10d773545d3 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 1 Jan 2024 22:20:21 +0800 Subject: [PATCH] Add Event2 stop handling test. --- test/common/Event2Test.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/common/Event2Test.cpp b/test/common/Event2Test.cpp index e14174cf..0d3222cc 100644 --- a/test/common/Event2Test.cpp +++ b/test/common/Event2Test.cpp @@ -39,4 +39,16 @@ TEST_CASE("Event2", "[event2]") { event.Raise(); REQUIRE(counter == 3); } + + SECTION("stop handling should work.") { + auto short_circuit_handler = [&counter](decltype(event)::Context* context) { + context->SetStopHandling(); + }; + + event.AddHandler(short_circuit_handler); + event.AddHandler(handler2); + + event.Raise(); + REQUIRE(counter == 1); + } }