mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-21 16:05:05 +00:00
Implement DispatcherThreadTest
This commit is contained in:
parent
b20dd09c9e
commit
c00ffa4fcf
29
Tests/TactilityCore/DispatcherThreadTest.cpp
Normal file
29
Tests/TactilityCore/DispatcherThreadTest.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include "doctest.h"
|
||||||
|
#include <Tactility/TactilityCore.h>
|
||||||
|
#include <Tactility/DispatcherThread.h>
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user