diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0b3ef569bb6f779875aacc94788e471b2e836135..f5227898afcfdf0bc0f4ca722ad11875fd60ef5b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -105,7 +105,7 @@ tests: - cd $CI_PROJECT_DIR - cmake . -DCMAKE_CXX_FLAGS="-g -O0 --coverage" && make tests -j$(nproc) - lcov -q --capture --initial --directory . -o coverage_base - - ./tests --use-colour yes + - ./tests --colour-mode ansi - lcov -q --capture --directory . -o coverage_tests - lcov -q -a coverage_base -a coverage_tests -o coverage_total_unfiltered - lcov -q --remove coverage_total_unfiltered "${PWD}/lib/*" "${PWD}/CMakeFiles/*" "${PWD}/test/*" "${PWD}/src/main.cpp" -o coverage_total_filtered diff --git a/CMakeLists.txt b/CMakeLists.txt index 24ae6a8fd012616ff86b4a546faef0c52dd084a2..78e2b55f39ac15dec424e76208755a2c3a6f77c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,5 +73,5 @@ IF (EXISTS "${PROJECT_SOURCE_DIR}/lib/Catch2/CMakeLists.txt") ${test_main_SRC} ${test_SRC} ) - target_link_libraries(tests Catch2::Catch2) + target_link_libraries(tests Catch2::Catch2WithMain) ENDIF () diff --git a/lib/Catch2 b/lib/Catch2 index d63307279412de3870cf97cc6802bae8ab36089e..605a34765aa5d5ecbf476b4598a862ada971b0cc 160000 --- a/lib/Catch2 +++ b/lib/Catch2 @@ -1 +1 @@ -Subproject commit d63307279412de3870cf97cc6802bae8ab36089e +Subproject commit 605a34765aa5d5ecbf476b4598a862ada971b0cc diff --git a/test/ErrorHandler.cpp b/test/ErrorHandler.cpp index 2db17bf40a7f120fa9e8e6b86e8df02c3d815d04..b5924e1803e5af7119fb87877085a92390103bd9 100644 --- a/test/ErrorHandler.cpp +++ b/test/ErrorHandler.cpp @@ -1,7 +1,7 @@ -#include <catch2/catch.hpp> #include <ErrorHandler.hpp> -#include "Services/ServiceTests.hpp" +#include <catch2/catch_all.hpp> #include "Services/RequestVerificationService.hpp" +#include "Services/ServiceTests.hpp" TEST_CASE("Error: Failed Acceptance", "[errors]") { Message failedMessage(38, 32, Message::TC, 47); diff --git a/test/Helpers/CRCHelper.cpp b/test/Helpers/CRCHelper.cpp index 5988eb3ee1be035397b87530493ef7d9e7b8526a..7d94c4f838bd26741a4556df41340f2e9b0289f4 100644 --- a/test/Helpers/CRCHelper.cpp +++ b/test/Helpers/CRCHelper.cpp @@ -1,11 +1,11 @@ -#include "catch2/catch.hpp" #include "Helpers/CRCHelper.hpp" +#include "catch2/catch_all.hpp" TEST_CASE("CRC calculation - Basic String tests") { - CHECK(CRCHelper::calculateCRC((uint8_t*)"Raccoon Squad!", 14) == 0x08FC); - CHECK(CRCHelper::calculateCRC((uint8_t*)"ASAT", 4) == 0xBFFA); - CHECK(CRCHelper::calculateCRC((uint8_t*)"All your space are belong to us", 31) == 0x545F); - CHECK(CRCHelper::calculateCRC((uint8_t*)"SPAAAAAAAAACE!", 14) == 0xB441); + CHECK(CRCHelper::calculateCRC((uint8_t*) "Raccoon Squad!", 14) == 0x08FC); + CHECK(CRCHelper::calculateCRC((uint8_t*) "ASAT", 4) == 0xBFFA); + CHECK(CRCHelper::calculateCRC((uint8_t*) "All your space are belong to us", 31) == 0x545F); + CHECK(CRCHelper::calculateCRC((uint8_t*) "SPAAAAAAAAACE!", 14) == 0xB441); } TEST_CASE("CRC calculation - Basic byte tests") { diff --git a/test/Helpers/PacketStore.cpp b/test/Helpers/PacketStore.cpp index 072303a5b3d8a4c5e92316eb3a446b9ff6e5eb21..ea50e7ed93db25c9ba3b2821975780a80cf8edab 100644 --- a/test/Helpers/PacketStore.cpp +++ b/test/Helpers/PacketStore.cpp @@ -1,5 +1,5 @@ #include "Helpers/PacketStore.hpp" -#include "catch2/catch.hpp" +#include "catch2/catch_all.hpp" TEST_CASE("Counting a packet store's size in bytes") { SECTION("Correct counting of size in bytes") { diff --git a/test/Helpers/PlatformParameters.cpp b/test/Helpers/PlatformParameters.cpp index adccb72716c9eb5979d953c3f97a1ba63858335b..833254a181d9b51481cd59923aba9cc2d12b41d1 100644 --- a/test/Helpers/PlatformParameters.cpp +++ b/test/Helpers/PlatformParameters.cpp @@ -1,7 +1,7 @@ #include "Platform/x86/Parameters/PlatformParameters.hpp" -#include "catch2/catch.hpp" #include "../Services/ServiceTests.hpp" #include "ECSS_Definitions.hpp" +#include "catch2/catch_all.hpp" TEST_CASE("Getting a reference of a parameter") { SECTION("Valid parameter requested") { diff --git a/test/Helpers/Statistic.cpp b/test/Helpers/Statistic.cpp index 5db84a3876685ace98f57408b009d48e4eb8fb3f..036d583950b11819260cbdd3c4ecf7b54fed8d9e 100644 --- a/test/Helpers/Statistic.cpp +++ b/test/Helpers/Statistic.cpp @@ -1,6 +1,6 @@ #include "Helpers/Statistic.hpp" #include "Services/ParameterStatisticsService.hpp" -#include "catch2/catch.hpp" +#include "catch2/catch_all.hpp" TEST_CASE("Statistics updating function") { SECTION("values in one by one") { @@ -17,25 +17,25 @@ TEST_CASE("Statistics updating function") { stat1.updateStatistics(value); CHECK(stat1.max == 3.24); CHECK(stat1.min == 1.3); - CHECK(stat1.mean == Approx(2.27).epsilon(0.01)); + CHECK(stat1.mean == Catch::Approx(2.27).epsilon(0.01)); value = 5.8; stat1.updateStatistics(value); CHECK(stat1.max == 5.8); CHECK(stat1.min == 1.3); - CHECK(stat1.mean == Approx(3.446).epsilon(0.001)); + CHECK(stat1.mean == Catch::Approx(3.446).epsilon(0.001)); } SECTION("Multiple consecutive values") { double values[10] = {8.3001, 2.3, 6.4, 1.1, 8.35, 3.4, 6, 8.31, 4.7, 1.09}; Statistic stat; CHECK(stat.statisticsAreInitialized()); - for (auto& value : values) { + for (auto& value: values) { stat.updateStatistics(value); } CHECK(stat.max == 8.35); CHECK(stat.min == 1.09); - CHECK(stat.mean == Approx(4.99501).epsilon(0.00001)); + CHECK(stat.mean == Catch::Approx(4.99501).epsilon(0.00001)); } } @@ -46,7 +46,7 @@ TEST_CASE("Appending of statistics to message") { double values[10] = {8.3001, 2.3, 6.4, 1.1, 8.35, 3.4, 6, 8.31, 4.7, 1.09}; Statistic stat; CHECK(stat.statisticsAreInitialized()); - for (auto& value : values) { + for (auto& value: values) { stat.updateStatistics(value); } stat.appendStatisticsToMessage(report); @@ -55,8 +55,8 @@ TEST_CASE("Appending of statistics to message") { REQUIRE(report.readUint32() == 0); // No CUC integration yet REQUIRE(report.readFloat() == 1.09f); REQUIRE(report.readUint32() == 0); - REQUIRE(report.readFloat() == Approx(4.99501).epsilon(0.00001)); - REQUIRE(report.readFloat() == Approx(2.76527).epsilon(0.00001)); + REQUIRE(report.readFloat() == Catch::Approx(4.99501).epsilon(0.00001)); + REQUIRE(report.readFloat() == Catch::Approx(2.76527).epsilon(0.00001)); } } @@ -74,7 +74,7 @@ TEST_CASE("Reset statistics") { double values[10] = {8.3001, 2.3, 6.4, 1.1, 8.35, 3.4, 6, 8.31, 4.7, 1.09}; Statistic stat; CHECK(stat.statisticsAreInitialized()); - for (auto& value : values) { + for (auto& value: values) { stat.updateStatistics(value); } CHECK(not stat.statisticsAreInitialized()); diff --git a/test/Message.cpp b/test/Message.cpp index 84a0c58d2fe440b0aa5d7c1918a3608581d8145d..e20e0769e47d128d7514692c28b4c825d2562cf2 100644 --- a/test/Message.cpp +++ b/test/Message.cpp @@ -1,8 +1,8 @@ -#include <catch2/catch.hpp> #include <Message.hpp> #include <ServicePool.hpp> -#include "etl/String.hpp" +#include <catch2/catch_all.hpp> #include "Services/EventReportService.hpp" +#include "etl/String.hpp" TEST_CASE("Message is usable", "[message]") { Message message(EventReportService::ServiceType, 17, Message::TC, 3); @@ -163,7 +163,7 @@ TEST_CASE("Test appending double") { REQUIRE(message.dataSize == 8); - CHECK(message.read<double>() == Approx(2.324).epsilon(0.0001)); + CHECK(message.read<double>() == Catch::Approx(2.324).epsilon(0.0001)); } TEST_CASE("Requirement 7.3.8 (Octet-string)", "[message][ecss]") { diff --git a/test/MessageParser.cpp b/test/MessageParser.cpp index 93cfa695a26cb1a97455db4c6e6ddf4310ec98c5..3a2f7b05b76b48f0e5df5ac31d27c8e702597d40 100644 --- a/test/MessageParser.cpp +++ b/test/MessageParser.cpp @@ -1,8 +1,8 @@ -#include <catch2/catch.hpp> +#include "MessageParser.hpp" #include <Message.hpp> +#include <catch2/catch_all.hpp> #include <cstring> #include "Helpers/CRCHelper.hpp" -#include "MessageParser.hpp" TEST_CASE("TC message parsing", "[MessageParser]") { uint8_t packet[] = {0x18, 0x07, 0xe0, 0x07, 0x00, 0x0a, 0x20, 0x81, 0x1f, 0x00, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f}; diff --git a/test/Services/EventActionService.cpp b/test/Services/EventActionService.cpp index 0d26065c77360f45dca03f13f0f1fe842064aa2c..54fae2ddf3e3066135d2dcf3003fc4d2f0afd8e6 100644 --- a/test/Services/EventActionService.cpp +++ b/test/Services/EventActionService.cpp @@ -1,15 +1,15 @@ -#include <catch2/catch.hpp> -#include <Services/EventActionService.hpp> #include <Message.hpp> -#include "ServiceTests.hpp" -#include <etl/String.hpp> -#include <cstring> #include <ServicePool.hpp> +#include <Services/EventActionService.hpp> +#include <catch2/catch_all.hpp> +#include <cstring> +#include <etl/String.hpp> +#include "ServiceTests.hpp" EventActionService& eventActionService = Services.eventAction; TEST_CASE("Add event-action definitions TC[19,1]", "[service][st19]") { - + // Add a message that is too large to check for the corresponding error Message message(EventActionService::ServiceType, EventActionService::MessageType::AddEventAction, Message::TC, 0); message.appendEnum16(0); @@ -198,7 +198,7 @@ TEST_CASE("Delete all event-action definitions TC[19,3]", "[service][st19]") { MessageParser::execute(message); // Checking the content of the map - for (int i = 0; i < 256; i++){ + for (int i = 0; i < 256; i++) { CHECK(eventActionService.eventActionDefinitionMap.find(i) == eventActionService.eventActionDefinitionMap.end()); } } @@ -410,6 +410,5 @@ TEST_CASE("Disable event-action function TC[19,9]", "[service][st19]") { CHECK(eventActionService.getEventActionFunctionStatus() == false); } -TEST_CASE("Execute a TC request", "[service][st19]"){ - +TEST_CASE("Execute a TC request", "[service][st19]") { } diff --git a/test/Services/EventReportService.cpp b/test/Services/EventReportService.cpp index 25a6b54f8a28f689ffb40198fb7ae9c86e1fed58..47f9bfaed247ab89cd56b0cd69a39f58fe0548c9 100644 --- a/test/Services/EventReportService.cpp +++ b/test/Services/EventReportService.cpp @@ -1,8 +1,8 @@ -#include <catch2/catch.hpp> -#include <Services/EventReportService.hpp> #include <Message.hpp> -#include "ServiceTests.hpp" +#include <Services/EventReportService.hpp> +#include <catch2/catch_all.hpp> #include <cstring> +#include "ServiceTests.hpp" EventReportService& eventReportService = Services.eventReport; diff --git a/test/Services/FunctionManagementService.cpp b/test/Services/FunctionManagementService.cpp index b6548d79b46bbcb482431b602130084874cd10b7..cf9f7a95db13cb5ebc5295c49cabcea0c78d7006 100644 --- a/test/Services/FunctionManagementService.cpp +++ b/test/Services/FunctionManagementService.cpp @@ -1,9 +1,9 @@ -#include "catch2/catch.hpp" #include "Services/FunctionManagementService.hpp" -#include "Services/RequestVerificationService.hpp" +#include <iostream> #include "ServicePool.hpp" #include "ServiceTests.hpp" -#include <iostream> +#include "Services/RequestVerificationService.hpp" +#include "catch2/catch_all.hpp" FunctionManagementService& fms = Services.functionManagement; @@ -20,7 +20,7 @@ TEST_CASE("ST[08] - Call Tests") { fms.include(String<ECSSFunctionNameLength>("test"), &test); Message msg(FunctionManagementService::ServiceType, FunctionManagementService::MessageType::PerformFunction, - Message::TC, 1); + Message::TC, 1); msg.appendFixedString(String<ECSSFunctionNameLength>("test")); msg.appendByte(199); @@ -52,8 +52,7 @@ TEST_CASE("ST[08] - Call Tests") { fms.include(String<ECSSFunctionNameLength>("test"), &test); Message msg(FunctionManagementService::ServiceType, FunctionManagementService::MessageType::PerformFunction, Message::TC, 1); msg.appendFixedString(String<ECSSFunctionNameLength>("test")); - msg.appendString(String<65> - ("eqrhjweghjhwqgthjkrghthjkdsfhgsdfhjsdjsfdhgkjdfsghfjdgkdfsgdfgsgd")); + msg.appendString(String<65>("eqrhjweghjhwqgthjkrghthjkdsfhgsdfhjsdjsfdhgkjdfsghfjdgkdfsgdfgsgd")); MessageParser::execute(msg); CHECK(ServiceTests::get(0).messageType == RequestVerificationService::MessageType::FailedStartOfExecution); diff --git a/test/Services/HousekeepingService.cpp b/test/Services/HousekeepingService.cpp index c4fec918d3564e717b230f50fe7679b97280f655..711a3035d606cd423d6b888c4655902c0378c72c 100644 --- a/test/Services/HousekeepingService.cpp +++ b/test/Services/HousekeepingService.cpp @@ -2,7 +2,7 @@ #include <iostream> #include "Message.hpp" #include "ServiceTests.hpp" -#include "catch2/catch.hpp" +#include "catch2/catch_all.hpp" #include "etl/algorithm.h" HousekeepingService& housekeepingService = Services.housekeeping; @@ -623,65 +623,65 @@ TEST_CASE("Reporting of housekeeping structure periodic properties") { } TEST_CASE("Periodically reporting Housekeeping Structures") { - uint32_t nextCollection = 0; + uint32_t nextCollection = 0; uint32_t currentTime = 0; uint32_t previousTime = 0; - SECTION("Non existent structures") { - nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); - CHECK(ServiceTests::count() == 0); - CHECK(nextCollection == std::numeric_limits<uint32_t>::max()); - } - SECTION("Collection Intervals set to max") { - initializeHousekeepingStructures(); - for (auto &housekeepingStructure: housekeepingService.housekeepingStructures) { - housekeepingStructure.second.collectionInterval = std::numeric_limits<uint32_t>::max(); - } - nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); - CHECK(ServiceTests::count() == 0); - CHECK(nextCollection == std::numeric_limits<uint32_t>::max()); - } - SECTION("Calculating properly defined collection intervals") { - housekeepingService.housekeepingStructures.at(0).collectionInterval = 900; - housekeepingService.housekeepingStructures.at(4).collectionInterval = 1000; - housekeepingService.housekeepingStructures.at(6).collectionInterval = 2700; - nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); + SECTION("Non existent structures") { + nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); + CHECK(ServiceTests::count() == 0); + CHECK(nextCollection == std::numeric_limits<uint32_t>::max()); + } + SECTION("Collection Intervals set to max") { + initializeHousekeepingStructures(); + for (auto& housekeepingStructure: housekeepingService.housekeepingStructures) { + housekeepingStructure.second.collectionInterval = std::numeric_limits<uint32_t>::max(); + } + nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); + CHECK(ServiceTests::count() == 0); + CHECK(nextCollection == std::numeric_limits<uint32_t>::max()); + } + SECTION("Calculating properly defined collection intervals") { + housekeepingService.housekeepingStructures.at(0).collectionInterval = 900; + housekeepingService.housekeepingStructures.at(4).collectionInterval = 1000; + housekeepingService.housekeepingStructures.at(6).collectionInterval = 2700; + nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); previousTime = currentTime; currentTime += nextCollection; - CHECK(currentTime == 900); - CHECK(ServiceTests::count() == 0); - nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); + CHECK(currentTime == 900); + CHECK(ServiceTests::count() == 0); + nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); previousTime = currentTime; currentTime += nextCollection; - CHECK(currentTime == 1000); - CHECK(ServiceTests::count() == 1); + CHECK(currentTime == 1000); + CHECK(ServiceTests::count() == 1); currentTime += 6; - nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); + nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); previousTime = currentTime; currentTime += nextCollection; - CHECK(currentTime == 1800); - CHECK(ServiceTests::count() == 2); - nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); + CHECK(currentTime == 1800); + CHECK(ServiceTests::count() == 2); + nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); previousTime = currentTime; currentTime += nextCollection; - CHECK(ServiceTests::count() == 3); - CHECK(currentTime == 2000); + CHECK(ServiceTests::count() == 3); + CHECK(currentTime == 2000); currentTime += 15; - nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); + nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); previousTime = currentTime; currentTime += nextCollection; - CHECK(ServiceTests::count() == 4); - CHECK(currentTime == 2700); - nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); + CHECK(ServiceTests::count() == 4); + CHECK(currentTime == 2700); + nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); previousTime = currentTime; currentTime += nextCollection; - CHECK(ServiceTests::count() == 6); - CHECK(currentTime == 3000); - } - SECTION("Collection Intervals set to 0") { - for (auto &housekeepingStructure: housekeepingService.housekeepingStructures) { - housekeepingStructure.second.collectionInterval = 0; - } - nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); - CHECK(nextCollection == 0); - } + CHECK(ServiceTests::count() == 6); + CHECK(currentTime == 3000); + } + SECTION("Collection Intervals set to 0") { + for (auto& housekeepingStructure: housekeepingService.housekeepingStructures) { + housekeepingStructure.second.collectionInterval = 0; + } + nextCollection = housekeepingService.reportPendingStructures(currentTime, previousTime, nextCollection); + CHECK(nextCollection == 0); + } } \ No newline at end of file diff --git a/test/Services/LargePacketTransferService.cpp b/test/Services/LargePacketTransferService.cpp index 100e7be06eefab28b11f39c6aa1dac58066f72eb..3cdb99433cb6420435bf3e2eb769dafdb6fa7418 100644 --- a/test/Services/LargePacketTransferService.cpp +++ b/test/Services/LargePacketTransferService.cpp @@ -1,10 +1,10 @@ -#include <catch2/catch.hpp> -#include <Services/LargePacketTransferService.hpp> #include <Message.hpp> -#include "ServiceTests.hpp" +#include <Services/LargePacketTransferService.hpp> +#include <catch2/catch_all.hpp> #include <cstring> #include <etl/String.hpp> #include "ECSS_Definitions.hpp" +#include "ServiceTests.hpp" LargePacketTransferService& lPT = Services.largePacketTransferService; @@ -70,19 +70,19 @@ TEST_CASE("Last Uplink Part TC[13,11]", "[service][st13]") { TEST_CASE("Split function", "[no][service]") { Message message(13, 0, Message::TC, 0); - for (uint16_t i = 0; i < 800; i++){ + for (uint16_t i = 0; i < 800; i++) { message.appendUint8(UINT8_MAX); } uint16_t largeMessageTransactionIdentifier = 1; lPT.split(message, largeMessageTransactionIdentifier); Message message5(13, 0, Message::TC, 0); - for (int i = 0; i < 4; i++){ + for (int i = 0; i < 4; i++) { uint16_t partSequenceNumber = i; CHECK(largeMessageTransactionIdentifier == ServiceTests::get(i).readUint16()); CHECK(partSequenceNumber == ServiceTests::get(i).readUint16()); CHECK(ECSSMaxFixedOctetStringSize == ServiceTests::get(i).readUint16()); - for (int j = 0; j < 256; j++){ + for (int j = 0; j < 256; j++) { message5.appendUint8(ServiceTests::get(i).readUint8()); } } diff --git a/test/Services/MemoryManagementService.cpp b/test/Services/MemoryManagementService.cpp index 5e99f191027fae3b4d2ed6c9f9608b8a14a3aa74..d37ac4c4a9f7c508c264cb94ebb01c15979d3228 100644 --- a/test/Services/MemoryManagementService.cpp +++ b/test/Services/MemoryManagementService.cpp @@ -1,8 +1,8 @@ -#include <catch2/catch.hpp> -#include <Services/MemoryManagementService.hpp> #include <Message.hpp> -#include "ServiceTests.hpp" +#include <Services/MemoryManagementService.hpp> +#include <catch2/catch_all.hpp> #include "Helpers/CRCHelper.hpp" +#include "ServiceTests.hpp" MemoryManagementService& memMangService = Services.memoryManagement; @@ -16,12 +16,12 @@ TEST_CASE("TC[6,2]", "[service][st06]") { Message receivedPacket = Message(MemoryManagementService::ServiceType, MemoryManagementService::MessageType::LoadRawMemoryDataAreas, Message::TC, 1); receivedPacket.appendEnum8(MemoryManagementService::MemoryID::EXTERNAL); // Memory ID - receivedPacket.appendUint16(2); // Iteration count - receivedPacket.appendUint64(reinterpret_cast<uint64_t>(pStr)); // Start address + receivedPacket.appendUint16(2); // Iteration count + receivedPacket.appendUint64(reinterpret_cast<uint64_t>(pStr)); // Start address receivedPacket.appendOctetString(String<2>(data)); - receivedPacket.appendBits(16, CRCHelper::calculateCRC(data, 2)); // Append CRC + receivedPacket.appendBits(16, CRCHelper::calculateCRC(data, 2)); // Append CRC receivedPacket.appendUint64(reinterpret_cast<uint64_t>(pStr + 2)); // Start address - receivedPacket.appendOctetString(String<1>(data)); // Append CRC + receivedPacket.appendOctetString(String<1>(data)); // Append CRC receivedPacket.appendBits(16, CRCHelper::calculateCRC(data, 1)); MessageParser::execute(receivedPacket); @@ -39,9 +39,9 @@ TEST_CASE("TC[6,5]", "[service][st06]") { uint16_t readSize = 0, checksum = 0; Message receivedPacket = Message(MemoryManagementService::ServiceType, MemoryManagementService::MessageType::DumpRawMemoryData, Message::TC, 1); - receivedPacket.appendEnum8(MemoryManagementService::MemoryID::EXTERNAL); // Memory ID - receivedPacket.appendUint16(3); // Iteration count (Equal to 3 test strings) - receivedPacket.appendUint64(reinterpret_cast<uint64_t>(testString_1)); // Start address + receivedPacket.appendEnum8(MemoryManagementService::MemoryID::EXTERNAL); // Memory ID + receivedPacket.appendUint16(3); // Iteration count (Equal to 3 test strings) + receivedPacket.appendUint64(reinterpret_cast<uint64_t>(testString_1)); // Start address receivedPacket.appendUint16(sizeof(testString_1) / sizeof(testString_1[0])); // Data read length receivedPacket.appendUint64(reinterpret_cast<uint64_t>(testString_2)); @@ -100,9 +100,9 @@ TEST_CASE("TC[6,9]", "[service][st06]") { uint16_t readSize = 0, checksum = 0; Message receivedPacket = Message(MemoryManagementService::ServiceType, MemoryManagementService::MessageType::CheckRawMemoryData, Message::TC, 1); - receivedPacket.appendEnum8(MemoryManagementService::MemoryID::EXTERNAL); // Memory ID - receivedPacket.appendUint16(2); // Iteration count - receivedPacket.appendUint64(reinterpret_cast<uint64_t>(testString_1)); // Start address + receivedPacket.appendEnum8(MemoryManagementService::MemoryID::EXTERNAL); // Memory ID + receivedPacket.appendUint16(2); // Iteration count + receivedPacket.appendUint64(reinterpret_cast<uint64_t>(testString_1)); // Start address receivedPacket.appendUint16(sizeof(testString_1) / sizeof(testString_1[0])); // Data read length receivedPacket.appendUint64(reinterpret_cast<uint64_t>(testString_2)); diff --git a/test/Services/OnBoardMonitoringService.cpp b/test/Services/OnBoardMonitoringService.cpp index 548cf83969d2fe97e21987e877dc6b147e7b3147..6e9074823189f79d775de4565c1b2509aa62aa7e 100644 --- a/test/Services/OnBoardMonitoringService.cpp +++ b/test/Services/OnBoardMonitoringService.cpp @@ -1,10 +1,10 @@ -#include <catch2/catch.hpp> -#include <Services/OnBoardMonitoringService.hpp> #include <Message.hpp> -#include "ServiceTests.hpp" -#include <etl/array.h> -#include <etl/String.hpp> #include <ServicePool.hpp> +#include <Services/OnBoardMonitoringService.hpp> +#include <catch2/catch_all.hpp> +#include <etl/String.hpp> +#include <etl/array.h> +#include "ServiceTests.hpp" OnBoardMonitoringService& onBoardMonitoringService = Services.onBoardMonitoringService; diff --git a/test/Services/Parameter.cpp b/test/Services/Parameter.cpp index 10c47ac78cebf73604199fa4aa3c4c56e6ee6fe0..d7b373f1289734445ccad5d589e2bfb4b791950e 100644 --- a/test/Services/Parameter.cpp +++ b/test/Services/Parameter.cpp @@ -1,8 +1,8 @@ -#include <iostream> -#include "catch2/catch.hpp" #include "Helpers/Parameter.hpp" -#include "Services/ParameterService.hpp" +#include <iostream> #include "Message.hpp" +#include "Services/ParameterService.hpp" +#include "catch2/catch_all.hpp" TEST_CASE("Parameter Append") { SECTION("Check correct appending") { @@ -49,24 +49,24 @@ TEST_CASE("Get value as double") { auto parameter1 = Parameter<uint8_t>(7); uint8_t value = 13; parameter1.setValue(value); - CHECK(parameter1.getValueAsDouble() == Approx(13.0).epsilon(0.1)); + CHECK(parameter1.getValueAsDouble() == Catch::Approx(13.0).epsilon(0.1)); } SECTION("uint16 to double") { auto parameter2 = Parameter<uint32_t>(8); uint16_t value = 264; parameter2.setValue(value); - CHECK(parameter2.getValueAsDouble() == Approx(264.0).epsilon(0.1)); + CHECK(parameter2.getValueAsDouble() == Catch::Approx(264.0).epsilon(0.1)); } SECTION("uint32 to double") { auto parameter3 = Parameter<uint32_t>(9); uint32_t value = 544; parameter3.setValue(value); - CHECK(parameter3.getValueAsDouble() == Approx(544.0).epsilon(0.1)); + CHECK(parameter3.getValueAsDouble() == Catch::Approx(544.0).epsilon(0.1)); } SECTION("float to double") { auto parameter4 = Parameter<float>(10); float value = 14.237; parameter4.setValue(value); - CHECK(parameter4.getValueAsDouble() == Approx(14.237).epsilon(0.001)); + CHECK(parameter4.getValueAsDouble() == Catch::Approx(14.237).epsilon(0.001)); } } diff --git a/test/Services/ParameterService.cpp b/test/Services/ParameterService.cpp index 018bc9af98dabca06187836692cdf81695b5741c..fc3a480372f546a6eafa0245d30e53fd82a1d02c 100644 --- a/test/Services/ParameterService.cpp +++ b/test/Services/ParameterService.cpp @@ -1,8 +1,8 @@ -#include "catch2/catch.hpp" -#include "Message.hpp" -#include "ServiceTests.hpp" #include "Services/ParameterService.hpp" +#include "Message.hpp" #include "Parameters/PlatformParameters.hpp" +#include "ServiceTests.hpp" +#include "catch2/catch_all.hpp" static void resetParameterValues() { PlatformParameters::parameter1.setValue(3); diff --git a/test/Services/ParameterStatisticsService.cpp b/test/Services/ParameterStatisticsService.cpp index fbc1c361efd386cfd25a92d5a53c048d0212280c..8f712121feb39681897ce66ab6aa5955ba083a45 100644 --- a/test/Services/ParameterStatisticsService.cpp +++ b/test/Services/ParameterStatisticsService.cpp @@ -1,8 +1,8 @@ #include <iostream> -#include "catch2/catch.hpp" +#include "ECSS_Definitions.hpp" #include "Message.hpp" #include "ServiceTests.hpp" -#include "ECSS_Definitions.hpp" +#include "catch2/catch_all.hpp" /** * System-statistics initialization, so there are actual statistics in the map to work with. @@ -52,18 +52,18 @@ TEST_CASE("Reporting of statistics") { CHECK(report.readUint16() == 6); // number of samples CHECK(report.readFloat() == 13); // max value CHECK(report.readUint32() == 0); // max time - CHECK(report.readFloat() == 3); // min value + CHECK(report.readFloat() == 3); // min value CHECK(report.readUint32() == 0); // min time - CHECK(report.readFloat() == 8); // mean - CHECK(report.readFloat() == Approx(3.41565).epsilon(0.01)); + CHECK(report.readFloat() == 8); // mean + CHECK(report.readFloat() == Catch::Approx(3.41565).epsilon(0.01)); // Parameter A - CHECK(report.readUint16() == 7); // ID-1 - CHECK(report.readUint16() == 3); // number of samples - CHECK(report.readFloat() == 5); // max value - CHECK(report.readUint32() == 0); // max time - CHECK(report.readFloat() == 1); // min value - CHECK(report.readUint32() == 0); // min time - CHECK(report.readFloat() == 3); // mean + CHECK(report.readUint16() == 7); // ID-1 + CHECK(report.readUint16() == 3); // number of samples + CHECK(report.readFloat() == 5); // max value + CHECK(report.readUint32() == 0); // max time + CHECK(report.readFloat() == 1); // min value + CHECK(report.readUint32() == 0); // min time + CHECK(report.readFloat() == 3); // mean CHECK(static_cast<int>(report.readFloat()) == 1); // stddev CHECK(not Services.parameterStatistics.statisticsMap[5].statisticsAreInitialized()); @@ -372,9 +372,9 @@ TEST_CASE("Parameter statistics definition report") { CHECK(ServiceTests::count() == 1); Message report = ServiceTests::get(0); - CHECK(report.readUint16() == 0); // Reporting interval - CHECK(report.readUint16() == 2); // Num of valid Ids - CHECK(report.readUint16() == 5); // Valid parameter ID + CHECK(report.readUint16() == 0); // Reporting interval + CHECK(report.readUint16() == 2); // Num of valid Ids + CHECK(report.readUint16() == 5); // Valid parameter ID CHECK(report.readUint16() == 12); // Sampling interval CHECK(report.readUint16() == 7); CHECK(report.readUint16() == 0); diff --git a/test/Services/RealTimeForwardingControl.cpp b/test/Services/RealTimeForwardingControl.cpp index 3553697dff0d3748aa67c78e75631653435972b0..e98ae59d320a3bf3216f563e9b43ac8ecd6e7bd3 100644 --- a/test/Services/RealTimeForwardingControl.cpp +++ b/test/Services/RealTimeForwardingControl.cpp @@ -3,7 +3,7 @@ #include "Message.hpp" #include "ServiceTests.hpp" #include "Services/RealTimeForwardingControlService.hpp" -#include "catch2/catch.hpp" +#include "catch2/catch_all.hpp" RealTimeForwardingControlService& realTimeForwarding = Services.realTimeForwarding; diff --git a/test/Services/RequestVerificationService.cpp b/test/Services/RequestVerificationService.cpp index 223cd1169c9d2688083d4b2dd7090a1e6d5b8254..8a46ee6386861653076c6eb4872d5fa51fa77da9 100644 --- a/test/Services/RequestVerificationService.cpp +++ b/test/Services/RequestVerificationService.cpp @@ -1,6 +1,6 @@ -#include <catch2/catch.hpp> -#include <Services/RequestVerificationService.hpp> #include <Message.hpp> +#include <Services/RequestVerificationService.hpp> +#include <catch2/catch_all.hpp> #include "ServiceTests.hpp" RequestVerificationService& reqVerifService = Services.requestVerification; @@ -13,17 +13,17 @@ TEST_CASE("TM[1,1]", "[service][st01]") { Message response = ServiceTests::get(0); // Checks for the data-members of the object response CHECK(response.serviceType == RequestVerificationService::ServiceType); - CHECK(response.messageType == RequestVerificationService::MessageType::SuccessfulAcceptanceReport); + CHECK(response.messageType == RequestVerificationService::MessageType::SuccessfulAcceptanceReport); CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 4); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number - CHECK(response.readEnumerated(1) == Message::TC); // packet type - CHECK(response.readBits(1) == 1); // secondary header flag - CHECK(response.readEnumerated(11) == 3); // application process ID - CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags - CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 1); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count } TEST_CASE("TM[1,2]", "[service][st01]") { @@ -34,17 +34,17 @@ TEST_CASE("TM[1,2]", "[service][st01]") { Message response = ServiceTests::get(0); // Checks for the data-members of the object response CHECK(response.serviceType == RequestVerificationService::ServiceType); - CHECK(response.messageType == RequestVerificationService::MessageType::FailedAcceptanceReport); + CHECK(response.messageType == RequestVerificationService::MessageType::FailedAcceptanceReport); CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 6); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) - CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number - CHECK(response.readEnumerated(1) == Message::TC); // packet type - CHECK(response.readBits(1) == 1); // secondary header flag - CHECK(response.readEnumerated(11) == 3); // application process ID - CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags - CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 1); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count CHECK(response.readEnum16() == ErrorHandler::UnknownAcceptanceError); // error code } @@ -56,17 +56,17 @@ TEST_CASE("TM[1,3]", "[service][st01]") { Message response = ServiceTests::get(0); // Checks for the data-members of the object response CHECK(response.serviceType == RequestVerificationService::ServiceType); - CHECK(response.messageType == RequestVerificationService::MessageType::SuccessfulStartOfExecution); + CHECK(response.messageType == RequestVerificationService::MessageType::SuccessfulStartOfExecution); CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 4); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number - CHECK(response.readEnumerated(1) == Message::TC); // packet type - CHECK(response.readBits(1) == 1); // secondary header flag - CHECK(response.readEnumerated(11) == 3); // application process ID - CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags - CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 1); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count } TEST_CASE("TM[1,4]", "[service][st01]") { @@ -77,17 +77,17 @@ TEST_CASE("TM[1,4]", "[service][st01]") { Message response = ServiceTests::get(0); // Checks for the data-members of the object response CHECK(response.serviceType == RequestVerificationService::ServiceType); - CHECK(response.messageType == RequestVerificationService::MessageType::FailedStartOfExecution); + CHECK(response.messageType == RequestVerificationService::MessageType::FailedStartOfExecution); CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 6); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) - CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number - CHECK(response.readEnumerated(1) == Message::TC); // packet type - CHECK(response.readBits(1) == 1); // secondary header flag - CHECK(response.readEnumerated(11) == 3); // application process ID - CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags - CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 1); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count CHECK(response.readEnum16() == ErrorHandler::UnknownExecutionStartError); // error code } @@ -99,18 +99,18 @@ TEST_CASE("TM[1,5]", "[service][st01]") { Message response = ServiceTests::get(0); // Checks for the data-members of the object response CHECK(response.serviceType == RequestVerificationService::ServiceType); - CHECK(response.messageType == RequestVerificationService::MessageType::SuccessfulProgressOfExecution); + CHECK(response.messageType == RequestVerificationService::MessageType::SuccessfulProgressOfExecution); CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 5); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number - CHECK(response.readEnumerated(1) == Message::TC); // packet type - CHECK(response.readBits(1) == 1); // secondary header flag - CHECK(response.readEnumerated(11) == 3); // application process ID - CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags - CHECK(response.readBits(14) == 0); // packet sequence count - CHECK(response.readByte() == 0); // step ID + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 1); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readByte() == 0); // step ID } TEST_CASE("TM[1,6]", "[service][st01]") { @@ -121,18 +121,18 @@ TEST_CASE("TM[1,6]", "[service][st01]") { Message response = ServiceTests::get(0); // Checks for the data-members of the object response CHECK(response.serviceType == RequestVerificationService::ServiceType); - CHECK(response.messageType == RequestVerificationService::MessageType::FailedProgressOfExecution); + CHECK(response.messageType == RequestVerificationService::MessageType::FailedProgressOfExecution); CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 7); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number - CHECK(response.readEnumerated(1) == Message::TC); // packet type - CHECK(response.readBits(1) == 1); // secondary header flag - CHECK(response.readEnumerated(11) == 3); // application process ID - CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags - CHECK(response.readBits(14) == 0); // packet sequence count - CHECK(response.readByte() == 0); // step ID + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 1); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readByte() == 0); // step ID CHECK(response.readEnum16() == ErrorHandler::UnknownExecutionProgressError); } @@ -144,17 +144,17 @@ TEST_CASE("TM[1,7]", "[service][st01]") { Message response = ServiceTests::get(0); // Checks for the data-members of the object response CHECK(response.serviceType == RequestVerificationService::ServiceType); - CHECK(response.messageType == RequestVerificationService::MessageType::SuccessfulCompletionOfExecution); + CHECK(response.messageType == RequestVerificationService::MessageType::SuccessfulCompletionOfExecution); CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 4); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number - CHECK(response.readEnumerated(1) == Message::TC); // packet type - CHECK(response.readBits(1) == 1); // secondary header flag - CHECK(response.readEnumerated(11) == 3); // application process ID - CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags - CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 1); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count } TEST_CASE("TM[1,8]", "[service][st01]") { @@ -164,17 +164,17 @@ TEST_CASE("TM[1,8]", "[service][st01]") { Message response = ServiceTests::get(0); CHECK(response.serviceType == RequestVerificationService::ServiceType); - CHECK(response.messageType == RequestVerificationService::MessageType::FailedCompletionOfExecution); + CHECK(response.messageType == RequestVerificationService::MessageType::FailedCompletionOfExecution); CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 6); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) - CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number - CHECK(response.readEnumerated(1) == Message::TC); // packet type - CHECK(response.readBits(1) == 1); // secondary header flag - CHECK(response.readEnumerated(11) == 3); // application process ID - CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags - CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 1); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count CHECK(response.readEnum16() == ErrorHandler::UnknownExecutionCompletionError); // error code } @@ -186,16 +186,16 @@ TEST_CASE("TM[1,10]", "[service][st01]") { Message response = ServiceTests::get(0); // Checks for the data-members of the object response CHECK(response.serviceType == RequestVerificationService::ServiceType); - CHECK(response.messageType == RequestVerificationService::MessageType::FailedRoutingReport); + CHECK(response.messageType == RequestVerificationService::MessageType::FailedRoutingReport); CHECK(response.packetType == Message::TM); // packet type CHECK(response.applicationId == 0); REQUIRE(response.dataSize == 6); // dataSize is the number of bytes of data array // Check for the value that is stored in <<data>> array(data-member of object response) - CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number - CHECK(response.readEnumerated(1) == Message::TC); // packet type - CHECK(response.readBits(1) == 1); // secondary header flag - CHECK(response.readEnumerated(11) == 3); // application process ID - CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags - CHECK(response.readBits(14) == 0); // packet sequence count + CHECK(response.readEnumerated(3) == CCSDSPacketVersion); // packet version number + CHECK(response.readEnumerated(1) == Message::TC); // packet type + CHECK(response.readBits(1) == 1); // secondary header flag + CHECK(response.readEnumerated(11) == 3); // application process ID + CHECK(response.readEnumerated(2) == ECSSSequenceFlags); // sequence flags + CHECK(response.readBits(14) == 0); // packet sequence count CHECK(response.readEnum16() == ErrorHandler::UnknownRoutingError); // error code } diff --git a/test/Services/StorageAndRetrievalService.cpp b/test/Services/StorageAndRetrievalService.cpp index fd7020db5c5f9deb294b670be75474fd0a45099b..15910597e2ef7e7b49a46b619a784588bc74555b 100644 --- a/test/Services/StorageAndRetrievalService.cpp +++ b/test/Services/StorageAndRetrievalService.cpp @@ -1,8 +1,8 @@ +#include "Services/StorageAndRetrievalService.hpp" #include <iostream> -#include "catch2/catch.hpp" #include "Message.hpp" #include "ServiceTests.hpp" -#include "Services/StorageAndRetrievalService.hpp" +#include "catch2/catch_all.hpp" StorageAndRetrievalService& storageAndRetrieval = Services.storageAndRetrieval; @@ -123,7 +123,7 @@ void padWithZeros(etl::array<String<ECSSPacketStoreIdSize>, 4>& packetStoreIds) uint8_t offsets[] = {3, 4, 5, 6}; int index = 0; // Padding every empty position with zeros, to avoid memory garbage collection, which leads to a faulty result. - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { uint8_t startingPosition = offsets[index++]; for (uint8_t i = startingPosition; i < ECSSPacketStoreIdSize; i++) { packetStoreId[i] = 0; @@ -134,16 +134,16 @@ void padWithZeros(etl::array<String<ECSSPacketStoreIdSize>, 4>& packetStoreIds) void addTelemetryPacketsInPacketStores() { auto packetStoreIds = validPacketStoreIds(); - for (auto& timestamp : timestamps1) { + for (auto& timestamp: timestamps1) { storageAndRetrieval.addTelemetryToPacketStore(packetStoreIds[0], timestamp); } - for (auto& timestamp : timestamps2) { + for (auto& timestamp: timestamps2) { storageAndRetrieval.addTelemetryToPacketStore(packetStoreIds[1], timestamp); } - for (auto& timestamp : timestamps3) { + for (auto& timestamp: timestamps3) { storageAndRetrieval.addTelemetryToPacketStore(packetStoreIds[2], timestamp); } - for (auto& timestamp : timestamps4) { + for (auto& timestamp: timestamps4) { storageAndRetrieval.addTelemetryToPacketStore(packetStoreIds[3], timestamp); } } @@ -242,7 +242,7 @@ TEST_CASE("Deleting packet stores") { uint16_t numOfPacketStores = 4; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { auto& packetStore = storageAndRetrieval.getPacketStore(packetStoreId); packetStore.storageStatus = false; packetStore.byTimeRangeRetrievalStatus = false; @@ -270,7 +270,7 @@ TEST_CASE("Deleting packet stores") { uint16_t numOfPacketStores = 0; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { auto& packetStore = storageAndRetrieval.getPacketStore(packetStoreId); packetStore.storageStatus = false; packetStore.byTimeRangeRetrievalStatus = false; @@ -297,7 +297,7 @@ TEST_CASE("Deleting packet stores") { uint16_t numOfPacketStores = 4; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { auto& packetStore = storageAndRetrieval.getPacketStore(packetStoreId); packetStore.storageStatus = false; packetStore.byTimeRangeRetrievalStatus = false; @@ -332,7 +332,7 @@ TEST_CASE("Deleting packet stores") { uint16_t numOfPacketStores = 4; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { REQUIRE(not storageAndRetrieval.packetStoreExists(packetStoreId)); request.appendString(packetStoreId); } @@ -358,7 +358,7 @@ TEST_CASE("Deleting packet stores") { uint16_t numOfPacketStores = 0; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { auto& packetStore = storageAndRetrieval.getPacketStore(packetStoreId); packetStore.storageStatus = false; packetStore.byTimeRangeRetrievalStatus = false; @@ -394,7 +394,7 @@ TEST_CASE("Deleting packet stores") { uint16_t numOfPacketStores = 8; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : correctPacketStoreIds) { + for (auto& packetStoreId: correctPacketStoreIds) { auto& packetStore = storageAndRetrieval.getPacketStore(packetStoreId); packetStore.storageStatus = false; packetStore.byTimeRangeRetrievalStatus = false; @@ -402,7 +402,7 @@ TEST_CASE("Deleting packet stores") { request.appendString(packetStoreId); } - for (auto& packetStoreId : wrongPacketStoreIds) { + for (auto& packetStoreId: wrongPacketStoreIds) { REQUIRE(not storageAndRetrieval.packetStoreExists(packetStoreId)); request.appendString(packetStoreId); } @@ -498,7 +498,7 @@ TEST_CASE("Enabling the storage of packet stores") { MessageParser::execute(request); CHECK(ServiceTests::count() == 0); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { REQUIRE(storageAndRetrieval.getPacketStore(packetStoreId).storageStatus == true); } @@ -578,7 +578,7 @@ TEST_CASE("Disabling the storage of packet stores") { MessageParser::execute(request); CHECK(ServiceTests::count() == 0); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { REQUIRE(storageAndRetrieval.getPacketStore(packetStoreId).storageStatus == false); } @@ -602,7 +602,7 @@ TEST_CASE("Changing the open retrieval start-time-tag") { request.appendUint32(startTimeTag); request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { REQUIRE(storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStartTimeTag == 0); storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStatus = PacketStore::Suspended; request.appendString(packetStoreId); @@ -677,7 +677,7 @@ TEST_CASE("Changing the open retrieval start-time-tag") { request.appendUint32(startTimeTag); request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { REQUIRE(storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStartTimeTag == 0); storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStatus = PacketStore::Suspended; } @@ -711,7 +711,7 @@ TEST_CASE("Resuming the open retrieval process") { uint16_t numOfPacketStores = 3; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = false; storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStatus = PacketStore::Suspended; request.appendString(packetStoreId); @@ -787,7 +787,7 @@ TEST_CASE("Resuming the open retrieval process") { uint16_t numOfPacketStores = 0; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = false; storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStatus = PacketStore::Suspended; } @@ -821,7 +821,7 @@ TEST_CASE("Suspending the open retrieval process") { uint16_t numOfPacketStores = 3; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStatus = PacketStore::InProgress; request.appendString(packetStoreId); } @@ -894,7 +894,7 @@ TEST_CASE("Suspending the open retrieval process") { uint16_t numOfPacketStores = 0; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { REQUIRE(storageAndRetrieval.packetStoreExists(packetStoreId)); storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStatus = PacketStore::InProgress; } @@ -930,7 +930,7 @@ TEST_CASE("Starting the by-time-range retrieval of packet stores") { uint32_t timeTags2[4] = {60, 70, 80, 90}; int index = 0; - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStatus = PacketStore::Suspended; storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = false; request.appendString(packetStoreId); @@ -1027,7 +1027,7 @@ TEST_CASE("Starting the by-time-range retrieval of packet stores") { uint16_t numOfPacketStores = 3; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStatus = PacketStore::Suspended; storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = false; request.appendString(packetStoreId); @@ -1047,7 +1047,7 @@ TEST_CASE("Starting the by-time-range retrieval of packet stores") { REQUIRE(storageAndRetrieval.getPacketStore(packetStoreIds[2]).byTimeRangeRetrievalStatus == false); REQUIRE(storageAndRetrieval.getPacketStore(packetStoreIds[3]).byTimeRangeRetrievalStatus == false); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { REQUIRE(storageAndRetrieval.getPacketStore(packetStoreId).retrievalStartTime == 0); } @@ -1069,7 +1069,7 @@ TEST_CASE("Aborting the by-time-range retrieval of packet stores") { uint16_t numOfPacketStores = 3; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStatus = PacketStore::Suspended; storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = true; request.appendString(packetStoreId); @@ -1100,7 +1100,7 @@ TEST_CASE("Aborting the by-time-range retrieval of packet stores") { uint16_t numOfPacketStores = 3; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : correctPacketStoreIds) { + for (auto& packetStoreId: correctPacketStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = true; } @@ -1114,7 +1114,7 @@ TEST_CASE("Aborting the by-time-range retrieval of packet stores") { CHECK(ServiceTests::count() == 3); CHECK(ServiceTests::countThrownErrors(ErrorHandler::NonExistingPacketStore) == 3); - for (auto& packetStoreId : correctPacketStoreIds) { + for (auto& packetStoreId: correctPacketStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = true; } @@ -1134,7 +1134,7 @@ TEST_CASE("Aborting the by-time-range retrieval of packet stores") { uint16_t numOfPacketStores = 0; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = true; } @@ -1165,7 +1165,7 @@ TEST_CASE("Reporting the status of packet stores") { uint8_t packetStoreData4[ECSSPacketStoreIdSize] = "ps5555"; int count = 0; - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { auto& packetStore = storageAndRetrieval.getPacketStore(packetStoreId); packetStore.storageStatus = (count % 2 == 0); packetStore.byTimeRangeRetrievalStatus = (count % 2 != 0); @@ -1228,7 +1228,7 @@ TEST_CASE("Reporting the configuration of packet stores") { uint8_t packetStoreData4[ECSSPacketStoreIdSize] = "ps5555"; int count = 0; - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).packetStoreType = (count % 2 == 0) ? PacketStore::Circular : PacketStore::Bounded; count++; @@ -1291,7 +1291,7 @@ TEST_CASE("Resizing the packet stores") { uint16_t numOfPacketStores = 3; request.appendUint16(numOfPacketStores); int index = 0; - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { auto& packetStore = storageAndRetrieval.getPacketStore(packetStoreId); packetStore.storageStatus = false; packetStore.openRetrievalStatus = PacketStore::Suspended; @@ -1328,7 +1328,7 @@ TEST_CASE("Resizing the packet stores") { uint16_t numOfPacketStores = 4; request.appendUint16(numOfPacketStores); int index = 0; - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { auto& packetStore = storageAndRetrieval.getPacketStore(packetStoreId); packetStore.storageStatus = (index % 2 == 0); packetStore.byTimeRangeRetrievalStatus = (index == 1); @@ -1347,7 +1347,7 @@ TEST_CASE("Resizing the packet stores") { CHECK(ServiceTests::countThrownErrors(ErrorHandler::GetPacketStoreWithByTimeRangeRetrieval) == 1); int i = 0; - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { REQUIRE(storageAndRetrieval.getPacketStore(packetStoreId).sizeInBytes == oldSizes[i++]); } @@ -1369,7 +1369,7 @@ TEST_CASE("Resizing the packet stores") { uint16_t numOfPacketStores = 4; request.appendUint16(numOfPacketStores); int index = 0; - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { auto& packetStore = storageAndRetrieval.getPacketStore(packetStoreId); packetStore.storageStatus = false; packetStore.byTimeRangeRetrievalStatus = false; @@ -1402,7 +1402,7 @@ TEST_CASE("Resizing the packet stores") { uint16_t numOfPacketStores = 4; request.appendUint16(numOfPacketStores); - for (auto& packetStoreId : wrongPacketStoreIds) { + for (auto& packetStoreId: wrongPacketStoreIds) { request.appendString(packetStoreId); request.appendUint16(35); } @@ -1412,7 +1412,7 @@ TEST_CASE("Resizing the packet stores") { CHECK(ServiceTests::count() == 4); CHECK(ServiceTests::countThrownErrors(ErrorHandler::NonExistingPacketStore) == 4); int i = 0; - for (auto& packetStoreId : correctPacketStoreIds) { + for (auto& packetStoreId: correctPacketStoreIds) { REQUIRE(storageAndRetrieval.getPacketStore(packetStoreId).sizeInBytes == oldSizes[i++]); } @@ -1428,7 +1428,7 @@ TEST_CASE("Changing the packet store type to circular") { auto packetStoreIds = validPacketStoreIds(); padWithZeros(packetStoreIds); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { auto& packetStore = storageAndRetrieval.getPacketStore(packetStoreId); packetStore.packetStoreType = PacketStore::Bounded; packetStore.storageStatus = false; @@ -1472,7 +1472,7 @@ TEST_CASE("Changing the packet store type to circular") { padWithZeros(correctPacketStoreIds); int count = 0; - for (auto& packetStoreId : correctPacketStoreIds) { + for (auto& packetStoreId: correctPacketStoreIds) { auto& packetStore = storageAndRetrieval.getPacketStore(packetStoreId); packetStore.packetStoreType = PacketStore::Bounded; packetStore.storageStatus = (count == 0); @@ -1482,7 +1482,7 @@ TEST_CASE("Changing the packet store type to circular") { } String<ECSSPacketStoreIdSize> finalIds[4] = {wrongPacketStoreIds[0], correctPacketStoreIds[0], - correctPacketStoreIds[1], correctPacketStoreIds[2]}; + correctPacketStoreIds[1], correctPacketStoreIds[2]}; ErrorHandler::ExecutionStartErrorType expectedErrors[4] = { ErrorHandler::ExecutionStartErrorType::NonExistingPacketStore, @@ -1517,7 +1517,7 @@ TEST_CASE("Changing the packet store type to bounded") { auto packetStoreIds = validPacketStoreIds(); padWithZeros(packetStoreIds); - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).packetStoreType = PacketStore::Circular; storageAndRetrieval.getPacketStore(packetStoreId).storageStatus = false; storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = false; @@ -1560,7 +1560,7 @@ TEST_CASE("Changing the packet store type to bounded") { padWithZeros(correctPacketStoreIds); int count = 0; - for (auto& packetStoreId : correctPacketStoreIds) { + for (auto& packetStoreId: correctPacketStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).packetStoreType = PacketStore::Circular; storageAndRetrieval.getPacketStore(packetStoreId).storageStatus = (count == 0); storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = (count == 1); @@ -1570,7 +1570,7 @@ TEST_CASE("Changing the packet store type to bounded") { } String<ECSSPacketStoreIdSize> finalIds[4] = {wrongPacketStoreIds[0], correctPacketStoreIds[0], - correctPacketStoreIds[1], correctPacketStoreIds[2]}; + correctPacketStoreIds[1], correctPacketStoreIds[2]}; ErrorHandler::ExecutionStartErrorType expectedErrors[4] = { ErrorHandler::ExecutionStartErrorType::NonExistingPacketStore, @@ -1607,7 +1607,7 @@ TEST_CASE("Changing the virtual channel of packet stores") { uint8_t virtualChannels[2] = {1, 5}; - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = false; storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStatus = PacketStore::Suspended; } @@ -1654,7 +1654,7 @@ TEST_CASE("Changing the virtual channel of packet stores") { uint8_t oldVirtualChannels[4] = {4, 6, 1, 2}; int count = 0; - for (auto& packetStoreId : correctPacketStoreIds) { + for (auto& packetStoreId: correctPacketStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = (count == 0); storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStatus = (count == 1) ? PacketStore::InProgress : PacketStore::Suspended; @@ -1662,7 +1662,7 @@ TEST_CASE("Changing the virtual channel of packet stores") { } String<ECSSPacketStoreIdSize> finalIds[4] = {wrongPacketStoreIds[0], correctPacketStoreIds[0], - correctPacketStoreIds[1], correctPacketStoreIds[2]}; + correctPacketStoreIds[1], correctPacketStoreIds[2]}; ErrorHandler::ExecutionStartErrorType expectedErrors[4] = { ErrorHandler::ExecutionStartErrorType::NonExistingPacketStore, @@ -1682,7 +1682,7 @@ TEST_CASE("Changing the virtual channel of packet stores") { } int index = 0; - for (auto& packetStoreId : correctPacketStoreIds) { + for (auto& packetStoreId: correctPacketStoreIds) { REQUIRE(storageAndRetrieval.getPacketStore(packetStoreId).virtualChannel == oldVirtualChannels[index]); index++; } @@ -1752,7 +1752,7 @@ TEST_CASE("Reporting the content summary of packet stores") { padWithZeros(packetStoreIds); int count = 0; - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStartTimeTag = (count == 3) ? 20 : 15; count++; } @@ -1823,7 +1823,7 @@ TEST_CASE("Reporting the content summary of packet stores") { padWithZeros(correctPacketStoreIds); String<ECSSPacketStoreIdSize> finalIds[3] = {wrongPacketStoreIds[0], wrongPacketStoreIds[1], - correctPacketStoreIds[0]}; + correctPacketStoreIds[0]}; storageAndRetrieval.getPacketStore(correctPacketStoreIds[0]).openRetrievalStartTimeTag = 5; @@ -1897,11 +1897,11 @@ TEST_CASE("Deleting packet store content") { uint32_t leftTimeStamps2[2]; int count = 0; - for (auto& tmPacket : storageAndRetrieval.getPacketStore(packetStoreIds[0]).storedTelemetryPackets) { + for (auto& tmPacket: storageAndRetrieval.getPacketStore(packetStoreIds[0]).storedTelemetryPackets) { leftTimeStamps1[count++] = tmPacket.first; } count = 0; - for (auto& tmPacket : storageAndRetrieval.getPacketStore(packetStoreIds[1]).storedTelemetryPackets) { + for (auto& tmPacket: storageAndRetrieval.getPacketStore(packetStoreIds[1]).storedTelemetryPackets) { leftTimeStamps2[count++] = tmPacket.first; } REQUIRE(storageAndRetrieval.getPacketStore(packetStoreIds[0]).storedTelemetryPackets.size() == 3); @@ -1949,11 +1949,11 @@ TEST_CASE("Deleting packet store content") { uint32_t leftTimeStamps2[8]; int count = 0; - for (auto& tmPacket : storageAndRetrieval.getPacketStore(packetStoreIds[2]).storedTelemetryPackets) { + for (auto& tmPacket: storageAndRetrieval.getPacketStore(packetStoreIds[2]).storedTelemetryPackets) { leftTimeStamps1[count++] = tmPacket.first; } count = 0; - for (auto& tmPacket : storageAndRetrieval.getPacketStore(packetStoreIds[3]).storedTelemetryPackets) { + for (auto& tmPacket: storageAndRetrieval.getPacketStore(packetStoreIds[3]).storedTelemetryPackets) { leftTimeStamps2[count++] = tmPacket.first; } REQUIRE(storageAndRetrieval.getPacketStore(packetStoreIds[2]).storedTelemetryPackets.size() == 4); @@ -2019,7 +2019,7 @@ TEST_CASE("Deleting packet store content") { request.appendUint16(numOfPacketStores); int count = 0; - for (auto& packetStoreId : packetStoreIds) { + for (auto& packetStoreId: packetStoreIds) { storageAndRetrieval.getPacketStore(packetStoreId).byTimeRangeRetrievalStatus = (count == 0); storageAndRetrieval.getPacketStore(packetStoreId).openRetrievalStatus = (count == 1) ? PacketStore::InProgress : PacketStore::Suspended; @@ -2050,15 +2050,15 @@ TEST_CASE("Deleting packet store content") { uint32_t leftTimeStamps4[6]; count = 0; - for (auto& tmPacket : storageAndRetrieval.getPacketStore(packetStoreIds[0]).storedTelemetryPackets) { + for (auto& tmPacket: storageAndRetrieval.getPacketStore(packetStoreIds[0]).storedTelemetryPackets) { leftTimeStamps1[count++] = tmPacket.first; } count = 0; - for (auto& tmPacket : storageAndRetrieval.getPacketStore(packetStoreIds[1]).storedTelemetryPackets) { + for (auto& tmPacket: storageAndRetrieval.getPacketStore(packetStoreIds[1]).storedTelemetryPackets) { leftTimeStamps2[count++] = tmPacket.first; } count = 0; - for (auto& tmPacket : storageAndRetrieval.getPacketStore(packetStoreIds[3]).storedTelemetryPackets) { + for (auto& tmPacket: storageAndRetrieval.getPacketStore(packetStoreIds[3]).storedTelemetryPackets) { leftTimeStamps4[count++] = tmPacket.first; } @@ -2083,7 +2083,7 @@ TEST_CASE("Deleting packet store content") { padWithZeros(correctPacketStoreIds); String<ECSSPacketStoreIdSize> finalIds[7] = { - wrongPacketStoreIds[0], wrongPacketStoreIds[1], wrongPacketStoreIds[2], correctPacketStoreIds[0], + wrongPacketStoreIds[0], wrongPacketStoreIds[1], wrongPacketStoreIds[2], correctPacketStoreIds[0], correctPacketStoreIds[1], correctPacketStoreIds[2], correctPacketStoreIds[3]}; Message request(StorageAndRetrievalService::ServiceType, @@ -2213,7 +2213,7 @@ TEST_CASE("Copying packets in time window, from tag to tag") { auto& targetPacketStore = storageAndRetrieval.getPacketStore(toPacketStoreId); REQUIRE(targetPacketStore.storedTelemetryPackets.size() == 2); int index = 0; - for (auto& tmPacket : targetPacketStore.storedTelemetryPackets) { + for (auto& tmPacket: targetPacketStore.storedTelemetryPackets) { REQUIRE(tmPacket.first == timestamps1[index++]); } @@ -2260,7 +2260,7 @@ TEST_CASE("Copying packets in time window, from tag to tag") { auto& targetPacketStore = storageAndRetrieval.getPacketStore(toPacketStoreId); REQUIRE(targetPacketStore.storedTelemetryPackets.size() == 4); int index = 3; - for (auto& tmPacket : targetPacketStore.storedTelemetryPackets) { + for (auto& tmPacket: targetPacketStore.storedTelemetryPackets) { REQUIRE(tmPacket.first == timestamps4[index++]); } @@ -2307,7 +2307,7 @@ TEST_CASE("Copying packets in time window, from tag to tag") { auto& targetPacketStore = storageAndRetrieval.getPacketStore(toPacketStoreId); REQUIRE(targetPacketStore.storedTelemetryPackets.size() == 3); int index = 2; - for (auto& tmPacket : targetPacketStore.storedTelemetryPackets) { + for (auto& tmPacket: targetPacketStore.storedTelemetryPackets) { REQUIRE(tmPacket.first == timestamps2[index++]); } @@ -2541,7 +2541,7 @@ TEST_CASE("Copying packets in time window, after time-tag") { uint32_t existingTimestamps[3]; int index = 0; - for (auto& tmPacket : targetPacketStore.storedTelemetryPackets) { + for (auto& tmPacket: targetPacketStore.storedTelemetryPackets) { existingTimestamps[index++] = tmPacket.first; } REQUIRE( @@ -2584,7 +2584,7 @@ TEST_CASE("Copying packets in time window, after time-tag") { uint32_t existingTimestamps[6]; int index = 0; - for (auto& tmPacket : targetPacketStore.storedTelemetryPackets) { + for (auto& tmPacket: targetPacketStore.storedTelemetryPackets) { existingTimestamps[index++] = tmPacket.first; } REQUIRE(std::equal(std::begin(timestamps1), std::end(timestamps1), std::begin(existingTimestamps))); @@ -2665,7 +2665,7 @@ TEST_CASE("Copying packets in time window, before time-tag") { uint32_t existingTimestamps[3]; int index = 0; - for (auto& tmPacket : targetPacketStore.storedTelemetryPackets) { + for (auto& tmPacket: targetPacketStore.storedTelemetryPackets) { existingTimestamps[index++] = tmPacket.first; } REQUIRE( @@ -2708,7 +2708,7 @@ TEST_CASE("Copying packets in time window, before time-tag") { uint32_t existingTimestamps[6]; int index = 0; - for (auto& tmPacket : targetPacketStore.storedTelemetryPackets) { + for (auto& tmPacket: targetPacketStore.storedTelemetryPackets) { existingTimestamps[index++] = tmPacket.first; } REQUIRE(std::equal(std::begin(timestamps1), std::end(timestamps1), std::begin(existingTimestamps))); diff --git a/test/Services/TestService.cpp b/test/Services/TestService.cpp index 7fb18f85a7c52fad0349ce9fbde5011736b13d7e..3424f95a81efec51d6db6358fd1c4ad6ca49dba4 100644 --- a/test/Services/TestService.cpp +++ b/test/Services/TestService.cpp @@ -1,6 +1,6 @@ -#include <catch2/catch.hpp> -#include <Services/TestService.hpp> #include <Message.hpp> +#include <Services/TestService.hpp> +#include <catch2/catch_all.hpp> #include "ServiceTests.hpp" TestService& testService = Services.testService; diff --git a/test/Services/TimeBasedSchedulingService.cpp b/test/Services/TimeBasedSchedulingService.cpp index c1f601b671e184b1d7db352b5f8f1487c0e9a7f3..5f74eb1cd61fdffbfbba401bdfbe79cdad151b85 100644 --- a/test/Services/TimeBasedSchedulingService.cpp +++ b/test/Services/TimeBasedSchedulingService.cpp @@ -1,6 +1,6 @@ -#include <catch2/catch.hpp> -#include "ServiceTests.hpp" #include <Services/TimeBasedSchedulingService.hpp> +#include <catch2/catch_all.hpp> +#include "ServiceTests.hpp" #include <ctime> #include <vector> @@ -10,8 +10,7 @@ * structure, which has been declared as a friend in the TimeBasedSchedulingService class, so * that it can access the private members required for testing validation. */ -namespace unit_test -{ +namespace unit_test { struct Tester { static bool executionFunctionStatus(TimeBasedSchedulingService& tmService) { return tmService.executionFunctionStatus; @@ -24,8 +23,9 @@ namespace unit_test static auto scheduledActivities(TimeBasedSchedulingService& tmService) { std::vector<TimeBasedSchedulingService::ScheduledActivity*> listElements; - std::transform(tmService.scheduledActivities.begin(), tmService.scheduledActivities.end(), - std::back_inserter(listElements), [](auto& activity) -> auto { return &activity; }); + std::transform( + tmService.scheduledActivities.begin(), tmService.scheduledActivities.end(), + std::back_inserter(listElements), [](auto& activity) -> auto { return &activity; }); return listElements; // Return the list elements } @@ -34,7 +34,7 @@ namespace unit_test Message testMessage1, testMessage2, testMessage3, testMessage4; auto currentTime = static_cast<uint32_t>(time(nullptr)); // Get the current system time -bool messagesPopulated = false; // Indicate whether the test messages are initialized +bool messagesPopulated = false; // Indicate whether the test messages are initialized // Run this function to set the service up before moving on with further testing auto activityInsertion(TimeBasedSchedulingService& timeService) { @@ -43,13 +43,13 @@ auto activityInsertion(TimeBasedSchedulingService& timeService) { testMessage1.serviceType = 6; testMessage1.messageType = 5; testMessage1.packetType = Message::TC; - testMessage1.applicationId = 8; // todo: Remove the dummy application ID + testMessage1.applicationId = 8; // todo: Remove the dummy application ID testMessage1.appendUint16(4253); // Append dummy data testMessage2.serviceType = 4; testMessage2.messageType = 5; testMessage2.packetType = Message::TC; - testMessage2.applicationId = 4; // todo: Remove the dummy application ID + testMessage2.applicationId = 4; // todo: Remove the dummy application ID testMessage2.appendUint16(45667); // Append dummy data testMessage3.serviceType = 3; @@ -91,13 +91,13 @@ auto activityInsertion(TimeBasedSchedulingService& timeService) { } -TimeBasedSchedulingService & timeBasedService = Services.timeBasedScheduling; +TimeBasedSchedulingService& timeBasedService = Services.timeBasedScheduling; TEST_CASE("TC[11,1] Enable Schedule Execution", "[service][st11]") { Services.reset(); Message receivedMessage(TimeBasedSchedulingService::ServiceType, TimeBasedSchedulingService::MessageType::EnableTimeBasedScheduleExecutionFunction, Message::TC, 1); - MessageParser::execute(receivedMessage);//timeService.enableScheduleExecution(receivedMessage); + MessageParser::execute(receivedMessage); //timeService.enableScheduleExecution(receivedMessage); CHECK(unit_test::Tester::executionFunctionStatus(timeBasedService)); } @@ -105,7 +105,7 @@ TEST_CASE("TC[11,2] Disable Schedule Execution", "[service][st11]") { Services.reset(); Message receivedMessage(TimeBasedSchedulingService::ServiceType, TimeBasedSchedulingService::MessageType::DisableTimeBasedScheduleExecutionFunction, Message::TC, 1); - MessageParser::execute(receivedMessage);//timeService.disableScheduleExecution(receivedMessage); + MessageParser::execute(receivedMessage); //timeService.disableScheduleExecution(receivedMessage); CHECK(not unit_test::Tester::executionFunctionStatus(timeBasedService)); } @@ -129,7 +129,7 @@ TEST_CASE("TC[11,4] Activity Insertion", "[service][st11]") { receivedMessage.appendUint16(1); // Total number of requests receivedMessage.appendUint32(currentTime - 15564350); - MessageParser::execute(receivedMessage);//timeService.insertActivities(receivedMessage); + MessageParser::execute(receivedMessage); //timeService.insertActivities(receivedMessage); REQUIRE(ServiceTests::thrownError(ErrorHandler::InstructionExecutionStartError)); } @@ -146,7 +146,7 @@ TEST_CASE("TC[11,15] Time shift all scheduled activities", "[service][st11]") { receivedMessage.appendSint32(-timeShift); CHECK(scheduledActivities.size() == 4); - MessageParser::execute(receivedMessage);//timeService.timeShiftAllActivities(receivedMessage); + MessageParser::execute(receivedMessage); //timeService.timeShiftAllActivities(receivedMessage); REQUIRE(scheduledActivities.at(0)->requestReleaseTime == currentTime + 1556435 - timeShift); REQUIRE(scheduledActivities.at(1)->requestReleaseTime == currentTime + 1726435 - timeShift); @@ -158,7 +158,7 @@ TEST_CASE("TC[11,15] Time shift all scheduled activities", "[service][st11]") { receivedMessage.appendSint32(timeShift); CHECK(scheduledActivities.size() == 4); - MessageParser::execute(receivedMessage);//timeService.timeShiftAllActivities(receivedMessage); + MessageParser::execute(receivedMessage); //timeService.timeShiftAllActivities(receivedMessage); REQUIRE(scheduledActivities.at(0)->requestReleaseTime == currentTime + 1556435 + timeShift); REQUIRE(scheduledActivities.at(1)->requestReleaseTime == currentTime + 1726435 + timeShift); @@ -170,7 +170,7 @@ TEST_CASE("TC[11,15] Time shift all scheduled activities", "[service][st11]") { receivedMessage.appendSint32(-6789000); // Provide a huge time shift to cause an error CHECK(scheduledActivities.size() == 4); - MessageParser::execute(receivedMessage);//timeService.timeShiftAllActivities(receivedMessage); + MessageParser::execute(receivedMessage); //timeService.timeShiftAllActivities(receivedMessage); REQUIRE(ServiceTests::thrownError(ErrorHandler::SubServiceExecutionStartError)); } @@ -187,11 +187,11 @@ TEST_CASE("TC[11,7] Time shift activities by ID", "[service][st11]") { const int32_t timeShift = 67890000; // Relative time-shift value SECTION("Positive Shift") { - receivedMessage.appendSint32(timeShift); // Time-shift value - receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity - receivedMessage.appendUint8(0); // Source ID is not implemented + receivedMessage.appendSint32(timeShift); // Time-shift value + receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity + receivedMessage.appendUint8(0); // Source ID is not implemented receivedMessage.appendUint16(testMessage2.applicationId); // todo: Remove the dummy app ID - receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count + receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count timeBasedService.timeShiftActivitiesByID(receivedMessage); scheduledActivities = unit_test::Tester::scheduledActivities(timeBasedService); @@ -202,11 +202,11 @@ TEST_CASE("TC[11,7] Time shift activities by ID", "[service][st11]") { } SECTION("Negative Shift") { - receivedMessage.appendSint32(-250000); // Time-shift value - receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity - receivedMessage.appendUint8(0); // Source ID is not implemented + receivedMessage.appendSint32(-250000); // Time-shift value + receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity + receivedMessage.appendUint8(0); // Source ID is not implemented receivedMessage.appendUint16(testMessage2.applicationId); // todo: Remove the dummy app ID - receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count + receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count timeBasedService.timeShiftActivitiesByID(receivedMessage); scheduledActivities = unit_test::Tester::scheduledActivities(timeBasedService); @@ -218,21 +218,21 @@ TEST_CASE("TC[11,7] Time shift activities by ID", "[service][st11]") { SECTION("Error throw on wrong request ID") { receivedMessage.appendSint32(-250000); // Time-shift value - receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity - receivedMessage.appendUint8(0); // Dummy source ID - receivedMessage.appendUint16(80); // Dummy application ID to throw an error - receivedMessage.appendUint16(0); // Dummy sequence count + receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity + receivedMessage.appendUint8(0); // Dummy source ID + receivedMessage.appendUint16(80); // Dummy application ID to throw an error + receivedMessage.appendUint16(0); // Dummy sequence count timeBasedService.timeShiftActivitiesByID(receivedMessage); REQUIRE(ServiceTests::thrownError(ErrorHandler::InstructionExecutionStartError)); } SECTION("Error throw on wrong time offset") { - receivedMessage.appendSint32(-6789000); // Time-shift value - receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity - receivedMessage.appendUint8(0); // Source ID is not implemented + receivedMessage.appendSint32(-6789000); // Time-shift value + receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity + receivedMessage.appendUint8(0); // Source ID is not implemented receivedMessage.appendUint16(testMessage2.applicationId); // todo: Remove the dummy app ID - receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count + receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count timeBasedService.timeShiftActivitiesByID(receivedMessage); REQUIRE(ServiceTests::thrownError(ErrorHandler::InstructionExecutionStartError)); @@ -251,14 +251,14 @@ TEST_CASE("TC[11,9] Detail report scheduled activities by ID", "[service][st11]" scheduledActivities.at(0)->requestID.applicationID = 8; // Append a dummy application ID scheduledActivities.at(2)->requestID.applicationID = 4; // Append a dummy application ID - receivedMessage.appendUint16(2); // Two instructions in the request - receivedMessage.appendUint8(0); // Source ID is not implemented + receivedMessage.appendUint16(2); // Two instructions in the request + receivedMessage.appendUint8(0); // Source ID is not implemented receivedMessage.appendUint16(testMessage2.applicationId); // todo: Remove the dummy app ID - receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count + receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count - receivedMessage.appendUint8(0); // Source ID is not implemented + receivedMessage.appendUint8(0); // Source ID is not implemented receivedMessage.appendUint16(testMessage1.applicationId); // todo: Remove the dummy app ID - receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count + receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count timeBasedService.detailReportActivitiesByID(receivedMessage); REQUIRE(ServiceTests::hasOneMessage()); @@ -288,10 +288,10 @@ TEST_CASE("TC[11,9] Detail report scheduled activities by ID", "[service][st11]" } SECTION("Error throw on wrong request ID") { - receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity - receivedMessage.appendUint8(0); // Dummy source ID + receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity + receivedMessage.appendUint8(0); // Dummy source ID receivedMessage.appendUint16(80); // Dummy application ID to throw an error - receivedMessage.appendUint16(0); // Dummy sequence count + receivedMessage.appendUint16(0); // Dummy sequence count timeBasedService.detailReportActivitiesByID(receivedMessage); REQUIRE(ServiceTests::thrownError(ErrorHandler::InstructionExecutionStartError)); @@ -310,14 +310,14 @@ TEST_CASE("TC[11,12] Summary report scheduled activities by ID", "[service][st11 scheduledActivities.at(0)->requestID.applicationID = 8; // Append a dummy application ID scheduledActivities.at(2)->requestID.applicationID = 4; // Append a dummy application ID - receivedMessage.appendUint16(2); // Two instructions in the request - receivedMessage.appendUint8(0); // Source ID is not implemented + receivedMessage.appendUint16(2); // Two instructions in the request + receivedMessage.appendUint8(0); // Source ID is not implemented receivedMessage.appendUint16(testMessage2.applicationId); // todo: Remove the dummy app ID - receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count + receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count - receivedMessage.appendUint8(0); // Source ID is not implemented + receivedMessage.appendUint8(0); // Source ID is not implemented receivedMessage.appendUint16(testMessage1.applicationId); // todo: Remove the dummy app ID - receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count + receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count timeBasedService.summaryReportActivitiesByID(receivedMessage); REQUIRE(ServiceTests::hasOneMessage()); @@ -348,10 +348,10 @@ TEST_CASE("TC[11,12] Summary report scheduled activities by ID", "[service][st11 } SECTION("Error throw on wrong request ID") { - receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity - receivedMessage.appendUint8(0); // Dummy source ID + receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity + receivedMessage.appendUint8(0); // Dummy source ID receivedMessage.appendUint16(80); // Dummy application ID to throw an error - receivedMessage.appendUint16(0); // Dummy sequence count + receivedMessage.appendUint16(0); // Dummy sequence count timeBasedService.summaryReportActivitiesByID(receivedMessage); REQUIRE(ServiceTests::thrownError(ErrorHandler::InstructionExecutionStartError)); @@ -397,10 +397,10 @@ TEST_CASE("TC[11,5] Activity deletion by ID", "[service][st11]") { CHECK(scheduledActivities.size() == 4); scheduledActivities.at(2)->requestID.applicationID = 4; // Append a dummy application ID - receivedMessage.appendUint16(1); // Just one instruction to delete an activity - receivedMessage.appendUint8(0); // Source ID is not implemented + receivedMessage.appendUint16(1); // Just one instruction to delete an activity + receivedMessage.appendUint8(0); // Source ID is not implemented receivedMessage.appendUint16(testMessage2.applicationId); // todo: Remove the dummy app ID - receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count + receivedMessage.appendUint16(0); // todo: Remove the dummy sequence count CHECK(scheduledActivities.size() == 4); timeBasedService.deleteActivitiesByID(receivedMessage); @@ -412,10 +412,10 @@ TEST_CASE("TC[11,5] Activity deletion by ID", "[service][st11]") { } SECTION("Error throw on wrong request ID") { - receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity - receivedMessage.appendUint8(0); // Dummy source ID + receivedMessage.appendUint16(1); // Just one instruction to time-shift an activity + receivedMessage.appendUint8(0); // Dummy source ID receivedMessage.appendUint16(80); // Dummy application ID to throw an error - receivedMessage.appendUint16(0); // Dummy sequence count + receivedMessage.appendUint16(0); // Dummy sequence count timeBasedService.deleteActivitiesByID(receivedMessage); REQUIRE(ServiceTests::thrownError(ErrorHandler::InstructionExecutionStartError)); diff --git a/test/TestPlatform.cpp b/test/TestPlatform.cpp index d5df134fce675f822a5fa7a5ea2f8e41e3bb23b4..d9ceaddfd223ded44d7b7295af1f434756be44b0 100644 --- a/test/TestPlatform.cpp +++ b/test/TestPlatform.cpp @@ -1,13 +1,13 @@ #define CATCH_CONFIG_EXTERNAL_INTERFACES -#include <catch2/catch.hpp> +#include <Logger.hpp> #include <Message.hpp> #include <Service.hpp> -#include <Logger.hpp> -#include "Services/ServiceTests.hpp" +#include <catch2/catch_all.hpp> #include "Helpers/Parameter.hpp" -#include "Services/ParameterService.hpp" #include "Parameters/PlatformParameters.hpp" +#include "Services/ParameterService.hpp" +#include "Services/ServiceTests.hpp" // Explicit template specializations for the logError() function template void ErrorHandler::logError(const Message&, ErrorHandler::AcceptanceErrorType); @@ -42,8 +42,8 @@ void Logger::log(Logger::LogLevel level, etl::istring& message) { // Logs while testing are completely ignored } -struct ServiceTestsListener : Catch::TestEventListenerBase { - using TestEventListenerBase::TestEventListenerBase; // inherit constructor +struct ServiceTestsListener : Catch::EventListenerBase { + using EventListenerBase::EventListenerBase; // inherit constructor void sectionEnded(Catch::SectionStats const& sectionStats) override { // Make sure we don't have any errors @@ -75,7 +75,7 @@ namespace PlatformParameters { inline Parameter<uint32_t> parameter10(43); inline Parameter<uint32_t> parameter11(91); inline Parameter<uint8_t> parameter12(1); -} +} // namespace PlatformParameters /** * Specific definition for \ref ParameterService's initialize function, for testing purposes. @@ -94,4 +94,4 @@ void ParameterService::initializeParameterMap() { {static_cast<uint16_t>(10), PlatformParameters::parameter11}, {static_cast<uint16_t>(11), PlatformParameters::parameter12}}; } -CATCH_REGISTER_LISTENER(ServiceTestsListener) +CATCH_REGISTER_LISTENER(ServiceTestsListener) \ No newline at end of file diff --git a/test/Time/TimeFormats.cpp b/test/Time/TimeFormats.cpp index 883af362b940848bb07bfe4cae5a117fb5178098..b5121afd6c60bc51556903dc5ccfc5cbbd44ff14 100644 --- a/test/Time/TimeFormats.cpp +++ b/test/Time/TimeFormats.cpp @@ -1,7 +1,7 @@ -#include "catch2/catch.hpp" +#include "../Services/ServiceTests.hpp" #include "Time/Time.hpp" #include "Time/UTCTimestamp.hpp" -#include "../Services/ServiceTests.hpp" +#include "catch2/catch_all.hpp" TEST_CASE("UTC timestamps") { // invalid year diff --git a/test/Time/TimeStamp.cpp b/test/Time/TimeStamp.cpp index ac99522ba966f817f7a048a615ab4782975007bd..f01a462ec53c55b38a1df9eb152690bda26671cd 100644 --- a/test/Time/TimeStamp.cpp +++ b/test/Time/TimeStamp.cpp @@ -1,5 +1,5 @@ -#include "catch2/catch.hpp" #include "Time/TimeStamp.hpp" +#include "catch2/catch_all.hpp" using namespace Time; diff --git a/test/tests.cpp b/test/tests.cpp index f481b16fe25e9b620f1dcf078a53f4f357d466c5..13928b9a80b6b91a1f06b6c17727c32de4098f69 100644 --- a/test/tests.cpp +++ b/test/tests.cpp @@ -1,3 +1,3 @@ #define CATCH_CONFIG_MAIN -#include <catch2/catch.hpp> +#include <catch2/catch_all.hpp>