Tactility/TactilityFreeRtos/Tests/Source/DispatcherThreadTest.cpp
Ken Van Hoeylandt f943c4dd69
Move tests to relevant subprojects (#615)
- Moved test projects to the parent project they belong to
- Improved test stability/corectness
- Improved recursive directory deletion by safely ignoring current- and parent-directory entries.
- Update docs
2026-08-13 23:01:12 +02:00

33 lines
706 B
C++

#include "doctest.h"
#include <Tactility/DispatcherThread.h>
#include <Tactility/Semaphore.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;
Semaphore done(1, 0);
thread.dispatch([&counter, &done]() {
counter++;
done.release();
});
CHECK(done.acquire(pdMS_TO_TICKS(2000)));
CHECK_EQ(counter, 1);
thread.stop();
}