finished creator unittests
This commit is contained in:
parent
ddf38b65c3
commit
3d2af203f2
@ -2,6 +2,7 @@
|
|||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "CatchDefinitions.h"
|
||||||
#include "fsfw/cfdp/FileSize.h"
|
#include "fsfw/cfdp/FileSize.h"
|
||||||
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h"
|
#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h"
|
||||||
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
|
#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h"
|
||||||
@ -9,7 +10,6 @@
|
|||||||
#include "fsfw/cfdp/pdu/HeaderSerializer.h"
|
#include "fsfw/cfdp/pdu/HeaderSerializer.h"
|
||||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||||
#include "fsfw/serialize/SerializeAdapter.h"
|
#include "fsfw/serialize/SerializeAdapter.h"
|
||||||
#include "CatchDefinitions.h"
|
|
||||||
|
|
||||||
TEST_CASE("CFDP Base", "[CfdpBase]") {
|
TEST_CASE("CFDP Base", "[CfdpBase]") {
|
||||||
using namespace cfdp;
|
using namespace cfdp;
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
#include <catch2/catch_approx.hpp>
|
#include <catch2/catch_approx.hpp>
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "LocalPoolOwnerBase.h"
|
|
||||||
#include "CatchDefinitions.h"
|
#include "CatchDefinitions.h"
|
||||||
|
#include "LocalPoolOwnerBase.h"
|
||||||
#include "tests/TestsConfig.h"
|
#include "tests/TestsConfig.h"
|
||||||
|
|
||||||
TEST_CASE("DataSetTest", "[DataSetTest]") {
|
TEST_CASE("DataSetTest", "[DataSetTest]") {
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "LocalPoolOwnerBase.h"
|
|
||||||
#include "CatchDefinitions.h"
|
#include "CatchDefinitions.h"
|
||||||
|
#include "LocalPoolOwnerBase.h"
|
||||||
|
|
||||||
TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
|
TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
|
||||||
LocalPoolOwnerBase* poolOwner =
|
LocalPoolOwnerBase* poolOwner =
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "LocalPoolOwnerBase.h"
|
|
||||||
#include "CatchDefinitions.h"
|
#include "CatchDefinitions.h"
|
||||||
|
#include "LocalPoolOwnerBase.h"
|
||||||
#include "tests/TestsConfig.h"
|
#include "tests/TestsConfig.h"
|
||||||
|
|
||||||
TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") {
|
TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") {
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "LocalPoolOwnerBase.h"
|
|
||||||
#include "CatchDefinitions.h"
|
#include "CatchDefinitions.h"
|
||||||
|
#include "LocalPoolOwnerBase.h"
|
||||||
#include "tests/TestsConfig.h"
|
#include "tests/TestsConfig.h"
|
||||||
|
|
||||||
TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") {
|
TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") {
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
#include "ComIFMock.h"
|
#include "ComIFMock.h"
|
||||||
#include "DeviceFdirMock.h"
|
#include "DeviceFdirMock.h"
|
||||||
#include "devicehandler/CookieIFMock.h"
|
|
||||||
#include "DeviceHandlerCommander.h"
|
#include "DeviceHandlerCommander.h"
|
||||||
#include "DeviceHandlerMock.h"
|
#include "DeviceHandlerMock.h"
|
||||||
|
#include "devicehandler/CookieIFMock.h"
|
||||||
#include "objects/systemObjectList.h"
|
#include "objects/systemObjectList.h"
|
||||||
|
|
||||||
TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
|
TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
#include "CatchDefinitions.h"
|
||||||
#include "catch2/catch_test_macros.hpp"
|
#include "catch2/catch_test_macros.hpp"
|
||||||
#include "fsfw/globalfunctions/CRC.h"
|
#include "fsfw/globalfunctions/CRC.h"
|
||||||
#include "CatchDefinitions.h"
|
|
||||||
|
|
||||||
TEST_CASE("CRC", "[CRC]") {
|
TEST_CASE("CRC", "[CRC]") {
|
||||||
std::array<uint8_t, 10> testData = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
std::array<uint8_t, 10> testData = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
#include "CatchDefinitions.h"
|
||||||
#include "catch2/catch_test_macros.hpp"
|
#include "catch2/catch_test_macros.hpp"
|
||||||
#include "fsfw/globalfunctions/DleEncoder.h"
|
#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_0 = {0, 0, 0, 0, 0};
|
||||||
const std::vector<uint8_t> TEST_ARRAY_1 = {0, DleEncoder::DLE_CHAR, 5};
|
const std::vector<uint8_t> TEST_ARRAY_1 = {0, DleEncoder::DLE_CHAR, 5};
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include "CatchDefinitions.h"
|
||||||
#include "fsfw/action/ActionMessage.h"
|
#include "fsfw/action/ActionMessage.h"
|
||||||
#include "fsfw/ipc/CommandMessage.h"
|
#include "fsfw/ipc/CommandMessage.h"
|
||||||
#include "fsfw/ipc/MessageQueueMessage.h"
|
#include "fsfw/ipc/MessageQueueMessage.h"
|
||||||
#include "fsfw/objectmanager/frameworkObjects.h"
|
#include "fsfw/objectmanager/frameworkObjects.h"
|
||||||
#include "CatchDefinitions.h"
|
|
||||||
#include "mocks/PeriodicTaskIFMock.h"
|
#include "mocks/PeriodicTaskIFMock.h"
|
||||||
|
|
||||||
TEST_CASE("Internal Error Reporter", "[TestInternalError]") {
|
TEST_CASE("Internal Error Reporter", "[TestInternalError]") {
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
|
#include "CatchDefinitions.h"
|
||||||
#include "fsfw/ipc/CommandMessage.h"
|
#include "fsfw/ipc/CommandMessage.h"
|
||||||
#include "fsfw/ipc/MessageQueueBase.h"
|
#include "fsfw/ipc/MessageQueueBase.h"
|
||||||
#include "fsfw/ipc/MessageQueueIF.h"
|
#include "fsfw/ipc/MessageQueueIF.h"
|
||||||
#include "fsfw/ipc/MessageQueueMessage.h"
|
#include "fsfw/ipc/MessageQueueMessage.h"
|
||||||
#include "CatchDefinitions.h"
|
|
||||||
|
|
||||||
class MessageQueueMockBase : public MessageQueueBase {
|
class MessageQueueMockBase : public MessageQueueBase {
|
||||||
public:
|
public:
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include <fsfw/power/DummyPowerSwitcher.h>
|
#include <fsfw/power/DummyPowerSwitcher.h>
|
||||||
#include <fsfw/power/PowerSwitcher.h>
|
#include <fsfw/power/PowerSwitcher.h>
|
||||||
#include "mocks/PowerSwitcherMock.h"
|
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include "mocks/PowerSwitcherMock.h"
|
||||||
#include "objects/systemObjectList.h"
|
#include "objects/systemObjectList.h"
|
||||||
|
|
||||||
TEST_CASE("Power Switcher", "[power-switcher]") {
|
TEST_CASE("Power Switcher", "[power-switcher]") {
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
|
|
||||||
#include "fsfw/version.h"
|
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "fsfw/serviceinterface.h"
|
|
||||||
#include "CatchDefinitions.h"
|
#include "CatchDefinitions.h"
|
||||||
|
#include "fsfw/serviceinterface.h"
|
||||||
|
#include "fsfw/version.h"
|
||||||
|
|
||||||
TEST_CASE("Version API Tests", "[TestVersionAPI]") {
|
TEST_CASE("Version API Tests", "[TestVersionAPI]") {
|
||||||
// Check that major version is non-zero
|
// Check that major version is non-zero
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
target_sources(${FSFW_TEST_TGT} PRIVATE
|
target_sources(${FSFW_TEST_TGT} PRIVATE
|
||||||
testCcsdsReader.cpp
|
TestCcsdsReader.cpp
|
||||||
)
|
)
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <cmath>
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include "fsfw/tmtcpacket/SpacePacketCreator.h"
|
#include "fsfw/tmtcpacket/SpacePacketCreator.h"
|
||||||
#include "fsfw/tmtcpacket/SpacePacketReader.h"
|
#include "fsfw/tmtcpacket/SpacePacketReader.h"
|
||||||
|
|
||||||
TEST_CASE("CCSDS Test", "[ccsds]") {
|
TEST_CASE("CCSDS Test", "[ccsds]") {
|
||||||
SpacePacketCreator base = SpacePacketCreator(
|
SpacePacketCreator base = SpacePacketCreator(ccsds::PacketType::TC, true, 0x02,
|
||||||
ccsds::PacketType::TC, true, 0x02,
|
|
||||||
ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16);
|
ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16);
|
||||||
std::array<uint8_t, 6> buf {};
|
std::array<uint8_t, 6> buf{};
|
||||||
uint8_t* bufPtr = buf.data();
|
uint8_t* bufPtr = buf.data();
|
||||||
size_t serLen = 0;
|
size_t serLen = 0;
|
||||||
|
|
||||||
@ -30,6 +29,14 @@ TEST_CASE("CCSDS Test", "[ccsds]") {
|
|||||||
REQUIRE(base.getPacketDataLen() == 0x16);
|
REQUIRE(base.getPacketDataLen() == 0x16);
|
||||||
REQUIRE(base.getPacketType() == ccsds::PacketType::TC);
|
REQUIRE(base.getPacketType() == ccsds::PacketType::TC);
|
||||||
REQUIRE(base.getPacketId() == 0x1802);
|
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") {
|
SECTION("Raw Output") {
|
||||||
@ -65,18 +72,33 @@ TEST_CASE("CCSDS Test", "[ccsds]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Invalid APID") {
|
SECTION("Invalid APID") {
|
||||||
SpacePacketCreator invalid = SpacePacketCreator(
|
SpacePacketCreator invalid =
|
||||||
PacketId(ccsds::PacketType::TC, true, 0xFFFF),
|
SpacePacketCreator(PacketId(ccsds::PacketType::TC, true, 0xFFFF),
|
||||||
PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16);
|
PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16);
|
||||||
REQUIRE(not invalid.isValid());
|
REQUIRE(not invalid.isValid());
|
||||||
REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED);
|
REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Invalid Seq Count") {
|
SECTION("Invalid Seq Count") {
|
||||||
SpacePacketCreator invalid = SpacePacketCreator(
|
SpacePacketCreator invalid =
|
||||||
PacketId(ccsds::PacketType::TC, true, 0x02),
|
SpacePacketCreator(PacketId(ccsds::PacketType::TC, true, 0x02),
|
||||||
PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0xFFFF), 0x16);
|
PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0xFFFF), 0x16);
|
||||||
REQUIRE(not invalid.isValid());
|
REQUIRE(not invalid.isValid());
|
||||||
REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user