mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 10:53:17 +00:00
- Bump version for next release - Fix default gamma for CYD 2432S032C - Remember gamma curve setting from Display settings app - Add UART to Core2 (still has no voltage on Grove port, though) - LVGL performance improvements: pin to second core and set task priority to "critical" - Fix build warnings, including deprecations - Removed deprecated `Thread` constructor - Fix WaveShare S3 display: Some displays would show a white screen at 12MHz, so I'm putting it back to the official config values.
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#include "doctest.h"
|
|
#include <Tactility/TactilityCore.h>
|
|
#include <Tactility/Mutex.h>
|
|
|
|
using namespace tt;
|
|
|
|
TEST_CASE("a mutex can block a thread") {
|
|
auto mutex = Mutex(Mutex::Type::Normal);
|
|
mutex.lock(portMAX_DELAY);
|
|
|
|
Thread thread = Thread(
|
|
"thread",
|
|
1024,
|
|
[&mutex]() {
|
|
mutex.lock(portMAX_DELAY);
|
|
return 0;
|
|
}
|
|
);
|
|
thread.start();
|
|
|
|
kernel::delayMillis(5);
|
|
CHECK_EQ(thread.getState(), Thread::State::Running);
|
|
|
|
mutex.unlock();
|
|
|
|
kernel::delayMillis(5);
|
|
CHECK_EQ(thread.getState(), Thread::State::Stopped);
|
|
|
|
thread.join();
|
|
}
|
|
|
|
TEST_CASE("a Mutex can be locked exactly once") {
|
|
auto mutex = Mutex(Mutex::Type::Normal);
|
|
CHECK_EQ(mutex.lock(0), true);
|
|
CHECK_EQ(mutex.lock(0), false);
|
|
CHECK_EQ(mutex.unlock(), true);
|
|
}
|
|
|
|
TEST_CASE("unlocking a Mutex without locking returns false") {
|
|
auto mutex = Mutex(Mutex::Type::Normal);
|
|
CHECK_EQ(mutex.unlock(), false);
|
|
}
|
|
|
|
TEST_CASE("unlocking a Mutex twice returns false on the second attempt") {
|
|
auto mutex = Mutex(Mutex::Type::Normal);
|
|
CHECK_EQ(mutex.lock(0), true);
|
|
CHECK_EQ(mutex.unlock(), true);
|
|
CHECK_EQ(mutex.unlock(), false);
|
|
}
|