Cleanup and improvements (#194)
- Lots of changes for migrating C code to C++ - Improved `Lockable` in several ways like adding `withLock()` (+ tests) - Improved `Semaphore` a bit for improved readability, and also added some tests - Upgrade Linux machine in GitHub Actions so that we can compile with a newer GCC - Simplification of WiFi connection - Updated funding options - (and more)
This commit is contained in:
committed by
GitHub
parent
1bb1260ea0
commit
6c67845645
@@ -0,0 +1,39 @@
|
||||
#include "Lockable.h"
|
||||
#include "Semaphore.h"
|
||||
#include "doctest.h"
|
||||
#include <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);
|
||||
CHECK_EQ(mutex->unlock(), true);
|
||||
}
|
||||
Reference in New Issue
Block a user