From e45a99143cdaf58175e20f9bcc896c5d66295ee7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 10 Aug 2022 09:45:24 +0200 Subject: [PATCH] added const char* test --- unittests/cfdp/testLvs.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/unittests/cfdp/testLvs.cpp b/unittests/cfdp/testLvs.cpp index b93458ed..c3f19d9c 100644 --- a/unittests/cfdp/testLvs.cpp +++ b/unittests/cfdp/testLvs.cpp @@ -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(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(rawBuf.data() + 1); + REQUIRE(std::strcmp(filename, filenameFromRaw) == 0); + } }