fsfw/unittests/mocks/StorageManagerMock.cpp

82 lines
2.9 KiB
C++
Raw Normal View History

#include "StorageManagerMock.h"
ReturnValue_t StorageManagerMock::addData(store_address_t *storageId, const uint8_t *data,
2022-11-14 14:57:37 +01:00
size_t size) {
2022-08-09 12:45:05 +02:00
if (nextAddDataCallFails.first) {
return nextAddDataCallFails.second;
}
2022-11-14 14:57:37 +01:00
return LocalPool::addData(storageId, data, size);
2022-08-09 12:45:05 +02:00
}
ReturnValue_t StorageManagerMock::deleteData(store_address_t packet_id) {
2022-08-09 13:04:23 +02:00
if (nextDeleteDataCallFails.first) {
2022-08-09 12:45:05 +02:00
return nextDeleteDataCallFails.second;
}
return LocalPool::deleteData(packet_id);
}
ReturnValue_t StorageManagerMock::deleteData(uint8_t *buffer, size_t size,
store_address_t *storeId) {
2022-08-09 13:04:23 +02:00
if (nextDeleteDataCallFails.first) {
2022-08-09 12:45:05 +02:00
return nextDeleteDataCallFails.second;
}
return LocalPool::deleteData(buffer, size, storeId);
}
ReturnValue_t StorageManagerMock::getData(store_address_t packet_id, const uint8_t **packet_ptr,
size_t *size) {
2022-08-09 12:45:05 +02:00
return LocalPool::getData(packet_id, packet_ptr, size);
}
ReturnValue_t StorageManagerMock::modifyData(store_address_t packet_id, uint8_t **packet_ptr,
size_t *size) {
2022-08-09 12:45:05 +02:00
if (nextModifyDataCallFails.first) {
return nextModifyDataCallFails.second;
}
return LocalPool::modifyData(packet_id, packet_ptr, size);
}
2022-08-09 12:50:50 +02:00
ReturnValue_t StorageManagerMock::getFreeElement(store_address_t *storageId, size_t size,
2022-11-14 14:57:37 +01:00
uint8_t **p_data) {
2022-08-09 12:50:50 +02:00
if (nextFreeElementCallFails.first) {
return nextFreeElementCallFails.second;
}
2022-11-14 14:57:37 +01:00
return LocalPool::getFreeElement(storageId, size, p_data);
}
2022-08-09 12:50:50 +02:00
2022-08-09 12:45:05 +02:00
bool StorageManagerMock::hasDataAtId(store_address_t storeId) const {
return LocalPool::hasDataAtId(storeId);
}
2022-08-09 13:04:23 +02:00
void StorageManagerMock::clearStore() { return LocalPool::clearStore(); }
2022-08-09 12:45:05 +02:00
void StorageManagerMock::clearSubPool(uint8_t poolIndex) {
return LocalPool::clearSubPool(poolIndex);
}
void StorageManagerMock::getFillCount(uint8_t *buffer, uint8_t *bytesWritten) {
return LocalPool::getFillCount(buffer, bytesWritten);
}
size_t StorageManagerMock::getTotalSize(size_t *additionalSize) {
return LocalPool::getTotalSize(additionalSize);
}
StorageManagerIF::max_subpools_t StorageManagerMock::getNumberOfSubPools() const {
return LocalPool::getNumberOfSubPools();
}
void StorageManagerMock::reset() {
clearStore();
nextAddDataCallFails.first = false;
2022-08-22 16:35:53 +02:00
nextAddDataCallFails.second = returnvalue::OK;
2022-08-09 12:45:05 +02:00
nextModifyDataCallFails.first = false;
2022-08-22 16:35:53 +02:00
nextModifyDataCallFails.second = returnvalue::OK;
2022-08-09 12:45:05 +02:00
nextDeleteDataCallFails.first = false;
2022-08-22 16:35:53 +02:00
nextDeleteDataCallFails.second = returnvalue::OK;
2022-08-09 12:50:50 +02:00
nextFreeElementCallFails.first = false;
2022-08-22 16:35:53 +02:00
nextFreeElementCallFails.second = returnvalue::OK;
2022-08-09 12:50:50 +02:00
}
StorageManagerMock::StorageManagerMock(object_id_t setObjectId,
const LocalPool::LocalPoolConfig &poolConfig)
2022-08-09 13:04:23 +02:00
: LocalPool(setObjectId, poolConfig) {}