2022-03-10 09:34:29 +01:00
|
|
|
|
|
|
|
#include "fsfw/version.h"
|
|
|
|
|
|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
|
|
|
|
|
|
#include "fsfw/serviceinterface.h"
|
|
|
|
#include "fsfw_tests/unit/CatchDefinitions.h"
|
|
|
|
|
|
|
|
TEST_CASE("Version API Tests", "[TestVersionAPI]") {
|
|
|
|
// Check that major version is non-zero
|
|
|
|
REQUIRE(fsfw::FSFW_VERSION.major > 0);
|
|
|
|
uint32_t fsfwMajor = fsfw::FSFW_VERSION.major;
|
2022-04-22 14:50:50 +02:00
|
|
|
REQUIRE(Version(255, 0, 0) > fsfw::FSFW_VERSION);
|
|
|
|
REQUIRE(Version(255, 0, 0) >= fsfw::FSFW_VERSION);
|
|
|
|
REQUIRE(Version(0, 0, 0) < fsfw::FSFW_VERSION);
|
|
|
|
REQUIRE(Version(0, 0, 0) <= fsfw::FSFW_VERSION);
|
|
|
|
Version v1 = fsfw::Version(1, 1, 1);
|
|
|
|
Version v2 = fsfw::Version(1, 1, 1);
|
2022-03-10 09:37:57 +01:00
|
|
|
REQUIRE(v1 == v2);
|
2022-04-22 14:04:30 +02:00
|
|
|
REQUIRE(not(v1 < v2));
|
|
|
|
REQUIRE(not(v1 > v2));
|
2022-03-10 09:37:57 +01:00
|
|
|
REQUIRE(v1 <= v2);
|
|
|
|
REQUIRE(v1 >= v2);
|
2022-03-10 09:34:29 +01:00
|
|
|
v1.revision -= 1;
|
|
|
|
REQUIRE(v1 != v2);
|
2022-04-22 14:04:30 +02:00
|
|
|
REQUIRE(not(v1 == v2));
|
|
|
|
REQUIRE(not(v1 > v2));
|
|
|
|
REQUIRE(not(v1 >= v2));
|
2022-03-10 09:34:29 +01:00
|
|
|
REQUIRE(v1 < v2);
|
|
|
|
REQUIRE(v1 <= v2);
|
|
|
|
v1.revision += 1;
|
|
|
|
v1.minor -= 1;
|
|
|
|
REQUIRE(v1 != v2);
|
|
|
|
REQUIRE(v1 < v2);
|
|
|
|
REQUIRE(v1 <= v2);
|
2022-04-22 14:04:30 +02:00
|
|
|
REQUIRE(not(v1 == v2));
|
|
|
|
REQUIRE(not(v1 > v2));
|
|
|
|
REQUIRE(not(v1 >= v2));
|
2022-03-10 09:34:29 +01:00
|
|
|
v1.minor += 1;
|
|
|
|
v1.major -= 1;
|
|
|
|
REQUIRE(v1 != v2);
|
|
|
|
REQUIRE(v1 < v2);
|
|
|
|
REQUIRE(v1 <= v2);
|
2022-04-22 14:04:30 +02:00
|
|
|
REQUIRE(not(v1 == v2));
|
|
|
|
REQUIRE(not(v1 > v2));
|
|
|
|
REQUIRE(not(v1 >= v2));
|
2022-03-10 09:34:29 +01:00
|
|
|
v1.major += 1;
|
|
|
|
REQUIRE(v1 == v2);
|
2022-03-10 09:37:57 +01:00
|
|
|
REQUIRE(v1 <= v2);
|
|
|
|
REQUIRE(v1 >= v2);
|
2022-04-22 14:04:30 +02:00
|
|
|
REQUIRE(not(v1 != v2));
|
|
|
|
REQUIRE(not(v1 > v2));
|
|
|
|
REQUIRE(not(v1 < v2));
|
2022-03-10 09:34:29 +01:00
|
|
|
v1.major += 1;
|
2022-03-10 09:44:06 +01:00
|
|
|
v1.minor -= 1;
|
2022-03-10 09:34:29 +01:00
|
|
|
REQUIRE(v1 != v2);
|
|
|
|
REQUIRE(v1 > v2);
|
|
|
|
REQUIRE(v1 >= v2);
|
2022-04-22 14:04:30 +02:00
|
|
|
REQUIRE(not(v1 == v2));
|
|
|
|
REQUIRE(not(v1 < v2));
|
|
|
|
REQUIRE(not(v1 <= v2));
|
2022-03-10 09:34:29 +01:00
|
|
|
v1.major -= 1;
|
2022-03-10 09:44:06 +01:00
|
|
|
v1.minor += 2;
|
|
|
|
v1.revision -= 1;
|
2022-03-10 09:34:29 +01:00
|
|
|
REQUIRE(v1 != v2);
|
|
|
|
REQUIRE(v1 > v2);
|
|
|
|
REQUIRE(v1 >= v2);
|
2022-04-22 14:04:30 +02:00
|
|
|
REQUIRE(not(v1 == v2));
|
|
|
|
REQUIRE(not(v1 < v2));
|
|
|
|
REQUIRE(not(v1 <= v2));
|
2022-03-10 09:34:29 +01:00
|
|
|
v1.minor -= 1;
|
2022-03-10 09:44:06 +01:00
|
|
|
v1.revision += 2;
|
2022-03-10 09:34:29 +01:00
|
|
|
REQUIRE(v1 != v2);
|
|
|
|
REQUIRE(v1 > v2);
|
|
|
|
REQUIRE(v1 >= v2);
|
2022-04-22 14:04:30 +02:00
|
|
|
REQUIRE(not(v1 == v2));
|
|
|
|
REQUIRE(not(v1 < v2));
|
|
|
|
REQUIRE(not(v1 <= v2));
|
2022-03-10 09:34:29 +01:00
|
|
|
v1.revision -= 1;
|
|
|
|
REQUIRE(v1 == v2);
|
2022-03-10 09:37:57 +01:00
|
|
|
REQUIRE(v1 <= v2);
|
|
|
|
REQUIRE(v1 >= v2);
|
2022-04-22 14:04:30 +02:00
|
|
|
REQUIRE(not(v1 != v2));
|
2022-03-10 09:40:34 +01:00
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2022-03-10 09:34:29 +01:00
|
|
|
sif::info << "v" << fsfw::FSFW_VERSION << std::endl;
|
2022-03-10 09:40:34 +01:00
|
|
|
#endif
|
2022-03-10 09:34:29 +01:00
|
|
|
char verString[10] = {};
|
|
|
|
fsfw::FSFW_VERSION.getVersion(verString, sizeof(verString));
|
2022-03-10 09:40:34 +01:00
|
|
|
#if FSFW_DISABLE_PRINTOUT == 0
|
2022-04-22 14:04:30 +02:00
|
|
|
printf("v%s\n", verString);
|
2022-03-10 09:40:34 +01:00
|
|
|
#endif
|
2022-03-10 09:34:29 +01:00
|
|
|
}
|