fsfw/tests/src/fsfw_tests/unit/timemanager/TestCountdown.cpp

29 lines
861 B
C++
Raw Normal View History

2021-09-27 21:53:27 +02:00
#include <fsfw/timemanager/Countdown.h>
2022-02-02 10:29:30 +01:00
2021-09-27 21:53:27 +02:00
#include <catch2/catch_test_macros.hpp>
2022-02-02 10:29:30 +01:00
#include "fsfw_tests/unit/CatchDefinitions.h"
2021-09-27 21:53:27 +02:00
2022-02-02 10:29:30 +01:00
TEST_CASE("Countdown Tests", "[TestCountdown]") {
INFO("Countdown Tests");
Countdown count(20);
REQUIRE(count.timeout == 20);
REQUIRE(count.setTimeout(100) == static_cast<uint16_t>(HasReturnvaluesIF::RETURN_OK));
REQUIRE(count.timeout == 100);
REQUIRE(count.setTimeout(150) == static_cast<uint16_t>(HasReturnvaluesIF::RETURN_OK));
REQUIRE(count.isBusy());
REQUIRE(not count.hasTimedOut());
uint32_t number = count.getRemainingMillis();
REQUIRE(number > 0);
bool blocked = false;
while (not count.hasTimedOut()) {
blocked = true;
};
REQUIRE(blocked);
number = count.getRemainingMillis();
REQUIRE(number == 0);
count.resetTimer();
REQUIRE(not count.hasTimedOut());
REQUIRE(count.isBusy());
2021-09-27 21:53:27 +02:00
}