mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
* **New Features** * Added public accessors for querying module/device start and ready state. * **Refactor** * Internal state moved to opaque internal objects; module/device/driver initializers now explicitly initialize internal pointers. * Lifecycle handling updated to construct/destruct internal state and use accessors. * **Tests** * Tests updated to use public accessors and explicit construct/destruct lifecycle calls. * **Chores** * Test build/include paths and small metadata updated.
40 lines
940 B
C++
40 lines
940 B
C++
#include "doctest.h"
|
|
#include <Tactility/Semaphore.h>
|
|
#include <Tactility/Lock.h>
|
|
#include <Tactility/Mutex.h>
|
|
|
|
using namespace tt;
|
|
|
|
TEST_CASE("withLock() locks correctly on Semaphore") {
|
|
auto semaphore = std::make_shared<Semaphore>(2U);
|
|
semaphore->withLock([semaphore](){
|
|
CHECK_EQ(semaphore->getAvailable(), 1);
|
|
});
|
|
}
|
|
|
|
TEST_CASE("withLock() unlocks correctly on Semaphore") {
|
|
auto semaphore = std::make_shared<Semaphore>(2U);
|
|
semaphore->withLock([=](){
|
|
// NO-OP
|
|
});
|
|
|
|
CHECK_EQ(semaphore->getAvailable(), 2);
|
|
}
|
|
|
|
TEST_CASE("withLock() locks correctly on Mutex") {
|
|
auto mutex = std::make_shared<Mutex>();
|
|
mutex->withLock([mutex](){
|
|
CHECK_EQ(mutex->lock(1), false);
|
|
});
|
|
}
|
|
|
|
TEST_CASE("withLock() unlocks correctly on Mutex") {
|
|
auto mutex = std::make_shared<Mutex>();
|
|
mutex->withLock([=](){
|
|
// NO-OP
|
|
});
|
|
|
|
CHECK_EQ(mutex->lock(1), true);
|
|
mutex->unlock();
|
|
}
|