From c00ffa4fcf68c8d501c20d7d954bac3d3eea3ada Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 31 Aug 2025 22:46:27 +0200 Subject: [PATCH] Implement DispatcherThreadTest --- Tests/TactilityCore/DispatcherThreadTest.cpp | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Tests/TactilityCore/DispatcherThreadTest.cpp diff --git a/Tests/TactilityCore/DispatcherThreadTest.cpp b/Tests/TactilityCore/DispatcherThreadTest.cpp new file mode 100644 index 00000000..346d509a --- /dev/null +++ b/Tests/TactilityCore/DispatcherThreadTest.cpp @@ -0,0 +1,29 @@ +#include "doctest.h" +#include +#include + +using namespace tt; + +TEST_CASE("DispatcherThread state test") { + DispatcherThread thread("test"); + CHECK_EQ(thread.isStarted(), false); + + thread.start(); + CHECK_EQ(thread.isStarted(), true); + + thread.stop(); + CHECK_EQ(thread.isStarted(), false); +} + +TEST_CASE("DispatcherThread should consume jobs") { + DispatcherThread thread("test"); + thread.start(); + int counter = 0; + + thread.dispatch([&counter]() { counter++; }); + + tt::kernel::delayTicks(10); + + CHECK_EQ(counter, 1); + thread.stop(); +}