Merge pull request 'Fix StorageAccessor move assignment' (#643) from gaisser/fsfw:gaisser_storage_accessor_fix into development

Reviewed-on: fsfw/fsfw#643
This commit is contained in:
Robin Müller 2022-06-21 10:31:36 +02:00
commit 541f563683
3 changed files with 29 additions and 1 deletions

View File

@ -13,7 +13,7 @@ StorageAccessor::StorageAccessor(store_address_t storeId, StorageManagerIF* stor
StorageAccessor& StorageAccessor::operator=(StorageAccessor&& other) {
// Call the parent move assignment and also assign own member.
dataPointer = other.dataPointer;
StorageAccessor::operator=(std::move(other));
ConstStorageAccessor::operator=(std::move(other));
return *this;
}

View File

@ -156,4 +156,31 @@ TEST_CASE("New Accessor", "[NewAccessor]") {
CHECK(receptionArray[i] == 42);
}
}
SECTION("Operators"){
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
{
StorageAccessor accessor(testStoreId);
StorageAccessor accessor2(0);
accessor2 = std::move(accessor);
REQUIRE(accessor.data() == nullptr);
std::array<uint8_t, 6> data;
size_t size = 6;
result = accessor.write(data.data(), data.size());
REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED);
result = SimplePool.modifyData(testStoreId, accessor2);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
CHECK(accessor2.getId() == testStoreId);
CHECK(accessor2.size() == 10);
std::array<uint8_t, 10> newData;
// Expect data to be invalid so this must return RETURN_FAILED
result = accessor.getDataCopy(newData.data(),newData.size());
REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED);
// Expect data to be too small
result = accessor2.getDataCopy(data.data(),data.size());
REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED);
}
}
}

View File

@ -3,6 +3,7 @@
#include <catch2/catch_test_macros.hpp>
#include <cstring>
#include <array>
#include "fsfw_tests/unit/CatchDefinitions.h"