added const char* test

This commit is contained in:
Robin Müller 2022-08-10 09:45:24 +02:00
parent 96dfe46e25
commit e45a99143c
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -93,7 +93,7 @@ TEST_CASE("CFDP TLV", "[cfdp][lv]") {
SerializeIF::STREAM_TOO_SHORT);
}
SECTION("String LV") {
SECTION("String LV String") {
std::string filename = "hello.txt";
StringLv sourceFileName(filename);
REQUIRE(sourceFileName.getSerializedSize() == 1 + filename.size());
@ -102,4 +102,15 @@ TEST_CASE("CFDP TLV", "[cfdp][lv]") {
std::string filenameFromRaw(reinterpret_cast<const char*>(rawBuf.data() + 1), filename.size());
REQUIRE(filenameFromRaw == filename);
}
SECTION("String LV Const Char") {
const char filename[] = "hello.txt";
StringLv sourceFileName(filename, sizeof(filename) - 1);
REQUIRE(sourceFileName.getSerializedSize() == 1 + sizeof(filename) - 1);
REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == result::OK);
REQUIRE(rawBuf[0] == sizeof(filename) - 1);
rawBuf[deserSize] = '\0';
const char* filenameFromRaw = reinterpret_cast<const char*>(rawBuf.data() + 1);
REQUIRE(std::strcmp(filename, filenameFromRaw) == 0);
}
}