finished creator unittests

This commit is contained in:
Robin Müller 2022-07-18 16:18:04 +02:00
parent ddf38b65c3
commit 3d2af203f2
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
15 changed files with 47 additions and 26 deletions

View File

@ -2,6 +2,7 @@
#include <catch2/catch_test_macros.hpp>
#include <cstring>
#include "CatchDefinitions.h"
#include "fsfw/cfdp/FileSize.h"
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h"
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
@ -9,7 +10,6 @@
#include "fsfw/cfdp/pdu/HeaderSerializer.h"
#include "fsfw/globalfunctions/arrayprinter.h"
#include "fsfw/serialize/SerializeAdapter.h"
#include "CatchDefinitions.h"
TEST_CASE("CFDP Base", "[CfdpBase]") {
using namespace cfdp;

View File

@ -8,8 +8,8 @@
#include <catch2/catch_approx.hpp>
#include <catch2/catch_test_macros.hpp>
#include "LocalPoolOwnerBase.h"
#include "CatchDefinitions.h"
#include "LocalPoolOwnerBase.h"
#include "tests/TestsConfig.h"
TEST_CASE("DataSetTest", "[DataSetTest]") {

View File

@ -11,8 +11,8 @@
#include <catch2/catch_test_macros.hpp>
#include <iostream>
#include "LocalPoolOwnerBase.h"
#include "CatchDefinitions.h"
#include "LocalPoolOwnerBase.h"
TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
LocalPoolOwnerBase* poolOwner =

View File

@ -3,8 +3,8 @@
#include <catch2/catch_test_macros.hpp>
#include "LocalPoolOwnerBase.h"
#include "CatchDefinitions.h"
#include "LocalPoolOwnerBase.h"
#include "tests/TestsConfig.h"
TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") {

View File

@ -3,8 +3,8 @@
#include <catch2/catch_test_macros.hpp>
#include "LocalPoolOwnerBase.h"
#include "CatchDefinitions.h"
#include "LocalPoolOwnerBase.h"
#include "tests/TestsConfig.h"
TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") {

View File

@ -2,9 +2,9 @@
#include "ComIFMock.h"
#include "DeviceFdirMock.h"
#include "devicehandler/CookieIFMock.h"
#include "DeviceHandlerCommander.h"
#include "DeviceHandlerMock.h"
#include "devicehandler/CookieIFMock.h"
#include "objects/systemObjectList.h"
TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {

View File

@ -1,8 +1,8 @@
#include <array>
#include "CatchDefinitions.h"
#include "catch2/catch_test_macros.hpp"
#include "fsfw/globalfunctions/CRC.h"
#include "CatchDefinitions.h"
TEST_CASE("CRC", "[CRC]") {
std::array<uint8_t, 10> testData = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

View File

@ -1,8 +1,8 @@
#include <array>
#include "CatchDefinitions.h"
#include "catch2/catch_test_macros.hpp"
#include "fsfw/globalfunctions/DleEncoder.h"
#include "CatchDefinitions.h"
const std::vector<uint8_t> TEST_ARRAY_0 = {0, 0, 0, 0, 0};
const std::vector<uint8_t> TEST_ARRAY_1 = {0, DleEncoder::DLE_CHAR, 5};

View File

@ -8,11 +8,11 @@
#include <array>
#include <catch2/catch_test_macros.hpp>
#include "CatchDefinitions.h"
#include "fsfw/action/ActionMessage.h"
#include "fsfw/ipc/CommandMessage.h"
#include "fsfw/ipc/MessageQueueMessage.h"
#include "fsfw/objectmanager/frameworkObjects.h"
#include "CatchDefinitions.h"
#include "mocks/PeriodicTaskIFMock.h"
TEST_CASE("Internal Error Reporter", "[TestInternalError]") {

View File

@ -4,11 +4,11 @@
#include <cstring>
#include <queue>
#include "CatchDefinitions.h"
#include "fsfw/ipc/CommandMessage.h"
#include "fsfw/ipc/MessageQueueBase.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/ipc/MessageQueueMessage.h"
#include "CatchDefinitions.h"
class MessageQueueMockBase : public MessageQueueBase {
public:

View File

@ -1,9 +1,9 @@
#include <fsfw/power/DummyPowerSwitcher.h>
#include <fsfw/power/PowerSwitcher.h>
#include "mocks/PowerSwitcherMock.h"
#include <catch2/catch_test_macros.hpp>
#include "mocks/PowerSwitcherMock.h"
#include "objects/systemObjectList.h"
TEST_CASE("Power Switcher", "[power-switcher]") {

View File

@ -1,10 +1,9 @@
#include "fsfw/version.h"
#include <catch2/catch_test_macros.hpp>
#include "fsfw/serviceinterface.h"
#include "CatchDefinitions.h"
#include "fsfw/serviceinterface.h"
#include "fsfw/version.h"
TEST_CASE("Version API Tests", "[TestVersionAPI]") {
// Check that major version is non-zero

View File

@ -1,3 +1,3 @@
target_sources(${FSFW_TEST_TGT} PRIVATE
testCcsdsReader.cpp
TestCcsdsReader.cpp
)

View File

@ -1,13 +1,12 @@
#include <array>
#include <cmath>
#include <catch2/catch_test_macros.hpp>
#include <cmath>
#include "fsfw/tmtcpacket/SpacePacketCreator.h"
#include "fsfw/tmtcpacket/SpacePacketReader.h"
TEST_CASE("CCSDS Test", "[ccsds]") {
SpacePacketCreator base = SpacePacketCreator(
ccsds::PacketType::TC, true, 0x02,
SpacePacketCreator base = SpacePacketCreator(ccsds::PacketType::TC, true, 0x02,
ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16);
std::array<uint8_t, 6> buf{};
uint8_t* bufPtr = buf.data();
@ -30,6 +29,14 @@ TEST_CASE("CCSDS Test", "[ccsds]") {
REQUIRE(base.getPacketDataLen() == 0x16);
REQUIRE(base.getPacketType() == ccsds::PacketType::TC);
REQUIRE(base.getPacketId() == 0x1802);
REQUIRE(base.getSerializedSize() == 6);
}
SECTION("Deserialization Fails") {
serLen = 6;
const uint8_t* readOnlyPtr = buf.data();
REQUIRE(base.deSerialize(&readOnlyPtr, &serLen, SerializeIF::Endianness::BIG) ==
HasReturnvaluesIF::RETURN_FAILED);
}
SECTION("Raw Output") {
@ -65,18 +72,33 @@ TEST_CASE("CCSDS Test", "[ccsds]") {
}
SECTION("Invalid APID") {
SpacePacketCreator invalid = SpacePacketCreator(
PacketId(ccsds::PacketType::TC, true, 0xFFFF),
SpacePacketCreator invalid =
SpacePacketCreator(PacketId(ccsds::PacketType::TC, true, 0xFFFF),
PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16);
REQUIRE(not invalid.isValid());
REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED);
}
SECTION("Invalid Seq Count") {
SpacePacketCreator invalid = SpacePacketCreator(
PacketId(ccsds::PacketType::TC, true, 0x02),
SpacePacketCreator invalid =
SpacePacketCreator(PacketId(ccsds::PacketType::TC, true, 0x02),
PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0xFFFF), 0x16);
REQUIRE(not invalid.isValid());
REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED);
}
SECTION("Invalid Buf Size 1") {
serLen = 2;
REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == SerializeIF::BUFFER_TOO_SHORT);
}
SECTION("Invalid Buf Size 2") {
serLen = 4;
REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == SerializeIF::BUFFER_TOO_SHORT);
}
SECTION("Invalid Buf Size 3") {
serLen = 6;
REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == SerializeIF::BUFFER_TOO_SHORT);
}
}