diff options
Diffstat (limited to 'test/base')
| -rw-r--r-- | test/base/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | test/base/Event2Test.cpp | 54 | ||||
| -rw-r--r-- | test/base/HandlerRegistryTest.cpp | 37 |
3 files changed, 0 insertions, 93 deletions
diff --git a/test/base/CMakeLists.txt b/test/base/CMakeLists.txt index 38cb9d57..f0a7f272 100644 --- a/test/base/CMakeLists.txt +++ b/test/base/CMakeLists.txt @@ -1,6 +1,4 @@ add_executable(CruBaseTest - Event2Test.cpp - HandlerRegistryTest.cpp PropertyTreeTest.cpp SelfResolvableTest.cpp StringUtilTest.cpp diff --git a/test/base/Event2Test.cpp b/test/base/Event2Test.cpp deleted file mode 100644 index 0c67f28e..00000000 --- a/test/base/Event2Test.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "cru/base/Event2.h" - -#include <catch2/catch_test_macros.hpp> - -using cru::Event2; - -TEST_CASE("Event2", "[event2]") { - Event2 event; - - int counter = 0; - - auto handler = [&counter] { counter++; }; - auto token = event.AddHandler(handler); - - auto handler2 = [&counter](decltype(event)::Context* context) { counter++; }; - - SECTION("two handlers should work.") { - event.Raise(); - REQUIRE(counter == 1); - event.Raise(); - REQUIRE(counter == 2); - - event.AddHandler(handler2); - event.Raise(); - REQUIRE(counter == 4); - } - - SECTION("handler revoker should work.") { - token.RevokeHandler(); - event.Raise(); - REQUIRE(counter == 0); - - token = event.AddHandler(handler); - event.AddHandler(handler2); - event.Raise(); - REQUIRE(counter == 2); - - token.RevokeHandler(); - 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); - } -} diff --git a/test/base/HandlerRegistryTest.cpp b/test/base/HandlerRegistryTest.cpp deleted file mode 100644 index aacef70f..00000000 --- a/test/base/HandlerRegistryTest.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "cru/base/HandlerRegistry.h" - -#include <catch2/catch_test_macros.hpp> - -#include <algorithm> - -TEST_CASE("HandlerRegistry", "[handler_registry]") { - using namespace cru; - HandlerRegistry<void()> registry; - - int counter = 1; - - auto tag1 = registry.AddHandler([&counter] { counter++; }); - auto tag2 = registry.AddHandler([&counter] { counter++; }); - - for (const auto& handler : registry) { - handler(); - } - - REQUIRE(counter == 3); - - registry.RemoveHandler(tag1); - - for (const auto& handler : registry) { - handler(); - } - - REQUIRE(counter == 4); - - registry.RemoveHandler(tag2); - - for (const auto& handler : registry) { - handler(); - } - - REQUIRE(counter == 4); -} |
