test put request

This commit is contained in:
Robin Müller 2023-07-26 17:29:35 +02:00
parent fde277cd06
commit 291c75c01f
Signed by: muellerr
GPG Key ID: 407F9B00F858F270

View File

@ -1,3 +1,40 @@
#include <array>
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
TEST_CASE("Put Request", "[cfdp]") {} #include "fsfw/cfdp/handler/PutRequest.h"
#include "fsfw/cfdp/tlv/ReservedMessageCreator.h"
TEST_CASE("Put Request", "[cfdp]") {
using namespace cfdp;
using namespace returnvalue;
std::array<uint8_t, 32> reservedMsgCustomData{};
std::array<uint8_t, 128> reservedMsgBuf{};
std::array<uint8_t, 128> buffer{};
EntityId destId(WidthInBytes::ONE_BYTE, 5);
std::string srcFileName = "hello.txt";
std::string destFileName = "hello2.txt";
uint8_t* msgBufPtr = reservedMsgCustomData.data();
size_t msgSize = 0;
cfdp::StringLv srcName(srcFileName);
cfdp::StringLv destName(destFileName);
CHECK(destId.serializeAsLv(&msgBufPtr, &msgSize, reservedMsgCustomData.size()) == OK);
CHECK(srcName.serialize(&msgBufPtr, &msgSize, reservedMsgCustomData.size(),
SerializeIF::Endianness::NETWORK) == OK);
CHECK(destName.serialize(&msgBufPtr, &msgSize, reservedMsgCustomData.size(),
SerializeIF::Endianness::NETWORK) == OK);
ReservedMessageCreator creator(static_cast<uint8_t>(ProxyOpMessageType::PUT_REQUEST),
reservedMsgCustomData.data(), msgSize);
msgSize = 0;
ReturnValue_t result = creator.serializeBe(buffer.data(), msgSize, buffer.size());
CHECK(result == returnvalue::OK);
SECTION("Put Request with reserved message") {
PutRequest putRequest(destId, reservedMsgCustomData.data(), msgSize, nullptr, 0);
uint8_t* bufPtr = buffer.data();
size_t serLen = 0;
REQUIRE(putRequest.serialize(&bufPtr, &serLen, buffer.size(),
SerializeIF::Endianness::NETWORK) == OK);
CHECK(putRequest.getSerializedSize() == serLen);
}
}