EIVE upstream #29

Merged
muellerr merged 693 commits from use-eive-upstream into develop 2023-06-30 15:44:39 +02:00
4 changed files with 36 additions and 3 deletions
Showing only changes of commit bdd79d060d - Show all commits

View File

@ -10,6 +10,7 @@
namespace util {
struct RawData {
RawData() = default;
const uint8_t* data = nullptr;
size_t len = 0;
};
@ -17,8 +18,8 @@ struct RawData {
enum DataTypes { NONE, RAW, SERIALIZABLE };
union DataUnion {
RawData raw;
SerializeIF* serializable = nullptr;
RawData raw{};
SerializeIF* serializable;
};
struct DataWrapper {

View File

@ -1,3 +1,4 @@
target_sources(${FSFW_TEST_TGT} PRIVATE
testUnsignedByteField.cpp
testDataWrapper.cpp
)

View File

@ -0,0 +1,31 @@
#include <array>
#include <catch2/catch_test_macros.hpp>
#include "fsfw/util/dataWrapper.h"
#include "mocks/SimpleSerializable.h"
TEST_CASE("Data Wrapper", "[util]") {
util::DataWrapper wrapper;
SECTION("State") {
REQUIRE(wrapper.isNull());
}
SECTION("Set Raw Data") {
REQUIRE(wrapper.isNull());
std::array<uint8_t, 4> data = {1, 2, 3, 4};
wrapper.setRawData({data.data(), data.size()});
REQUIRE(not wrapper.isNull());
REQUIRE(wrapper.type == util::DataTypes::RAW);
REQUIRE(wrapper.dataUnion.raw.data == data.data());
REQUIRE(wrapper.dataUnion.raw.len == data.size());
}
SECTION("Simple Serializable") {
REQUIRE(wrapper.isNull());
SimpleSerializable serializable;
wrapper.setSerializable(serializable);
REQUIRE(not wrapper.isNull());
REQUIRE(wrapper.type == util::DataTypes::SERIALIZABLE);
REQUIRE(wrapper.dataUnion.serializable == &serializable);
}
}

View File

@ -4,7 +4,7 @@
#include "fsfw/util/UnsignedByteField.h"
TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") {
TEST_CASE("Unsigned Byte Field", "[util]") {
auto testByteField = UnsignedByteField<uint32_t>(10);
auto u32ByteField = U32ByteField(10);
auto u16ByteField = U16ByteField(5);