mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-20 07:25:06 +00:00
Fixes
This commit is contained in:
parent
2d867ac17a
commit
10cc269d9d
@ -24,8 +24,12 @@ class Semaphore final : public Lock {
|
||||
assert(initialAvailable <= maxCount);
|
||||
|
||||
if (maxCount == 1U) {
|
||||
assert(initialAvailable == maxCount); // TODO: Consider supporting this deviation
|
||||
return xSemaphoreCreateBinary();
|
||||
auto result = xSemaphoreCreateBinary();
|
||||
if (initialAvailable != 0U) {
|
||||
auto give_result = xSemaphoreGive(result);
|
||||
assert(give_result == pdPASS);
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return xSemaphoreCreateCounting(maxCount, initialAvailable);
|
||||
}
|
||||
|
||||
@ -5,13 +5,13 @@ using namespace tt;
|
||||
|
||||
TEST_CASE("TimerType::Periodic timers can be stopped and restarted") {
|
||||
int counter = 0;
|
||||
auto* timer = new Timer(Timer::Type::Periodic, [&counter]() { counter++; });
|
||||
timer->start(1);
|
||||
auto* timer = new Timer(Timer::Type::Periodic, 1, [&counter] { counter++; });
|
||||
CHECK_EQ(timer->start(), true);
|
||||
kernel::delayTicks(10);
|
||||
timer->stop();
|
||||
timer->start(1);
|
||||
CHECK_EQ(timer->stop(), true);
|
||||
CHECK_EQ(timer->start(), true);
|
||||
kernel::delayTicks(10);
|
||||
timer->stop();
|
||||
CHECK_EQ(timer->stop(), true);
|
||||
delete timer;
|
||||
|
||||
CHECK_GE(counter, 2);
|
||||
@ -20,10 +20,10 @@ TEST_CASE("TimerType::Periodic timers can be stopped and restarted") {
|
||||
TEST_CASE("TimerType::Periodic calls the callback periodically") {
|
||||
int ticks_to_run = 10;
|
||||
int counter = 0;
|
||||
auto* timer = new Timer(Timer::Type::Periodic, [&counter]() { counter++; });
|
||||
timer->start(1);
|
||||
auto* timer = new Timer(Timer::Type::Periodic, 1, [&counter] { counter++; });
|
||||
CHECK_EQ(timer->start(), true);
|
||||
kernel::delayTicks(ticks_to_run);
|
||||
timer->stop();
|
||||
CHECK_EQ(timer->stop(), true);
|
||||
delete timer;
|
||||
|
||||
CHECK_EQ(counter, ticks_to_run);
|
||||
@ -31,13 +31,13 @@ TEST_CASE("TimerType::Periodic calls the callback periodically") {
|
||||
|
||||
TEST_CASE("restarting TimerType::Once timers calls the callback again") {
|
||||
int counter = 0;
|
||||
auto* timer = new Timer(Timer::Type::Once, [&counter]() { counter++; });
|
||||
timer->start(1);
|
||||
auto* timer = new Timer(Timer::Type::Once, 1, [&counter] { counter++; });
|
||||
CHECK_EQ(timer->start(), true);
|
||||
kernel::delayTicks(10);
|
||||
timer->stop();
|
||||
timer->start(1);
|
||||
CHECK_EQ(timer->stop(), true);
|
||||
CHECK_EQ(timer->start(), true);
|
||||
kernel::delayTicks(10);
|
||||
timer->stop();
|
||||
CHECK_EQ(timer->stop(), true);
|
||||
delete timer;
|
||||
|
||||
CHECK_EQ(counter, 2);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user