Fix StorageAccessor move assignment

* Added Unittest for this
* Fixed missing include in test
This commit is contained in:
Steffen Gaisser 2022-06-20 15:15:33 +02:00
parent b18410aa63
commit b60e4bcb90
3 changed files with 21 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,23 @@ 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, 10> data;
size_t size = 10;
result = accessor.write(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);
}
}
}

View File

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