reapply clang format
This commit is contained in:
hal/src/fsfw_hal
common
devicehandlers
GyroL3GD20Handler.cppGyroL3GD20Handler.hMgmLIS3MDLHandler.cppMgmLIS3MDLHandler.hMgmRM3100Handler.cppMgmRM3100Handler.h
devicedefinitions
linux
stm32h7
src/fsfw
action.h
action
ActionHelper.cppActionHelper.hActionMessage.cppActionMessage.hCommandActionHelper.cppCommandActionHelper.hCommandsActionsIF.hHasActionsIF.hSimpleActionHelper.cppSimpleActionHelper.h
cfdp
CFDPHandler.cppCFDPHandler.hCFDPMessage.cppCFDPMessage.hFileSize.hdefinitions.h
pdu
AckInfo.cppAckInfo.hAckPduDeserializer.cppAckPduDeserializer.hAckPduSerializer.cppAckPduSerializer.hEofInfo.cppEofInfo.hEofPduDeserializer.cppEofPduDeserializer.hEofPduSerializer.cppEofPduSerializer.hFileDataDeserializer.cppFileDataDeserializer.hFileDataInfo.cppFileDataInfo.hFileDataSerializer.cppFileDataSerializer.hFileDirectiveDeserializer.cppFileDirectiveDeserializer.hFileDirectiveSerializer.cppFileDirectiveSerializer.hFinishedInfo.cppFinishedInfo.hFinishedPduDeserializer.cppFinishedPduDeserializer.hFinishedPduSerializer.cppFinishedPduSerializer.hHeaderDeserializer.cppHeaderDeserializer.hHeaderSerializer.cppHeaderSerializer.hKeepAlivePduDeserializer.cppKeepAlivePduDeserializer.hKeepAlivePduSerializer.cppKeepAlivePduSerializer.hMetadataInfo.cppMetadataInfo.hMetadataPduDeserializer.cppMetadataPduDeserializer.hMetadataPduSerializer.cppMetadataPduSerializer.hNakInfo.cppNakInfo.hNakPduDeserializer.cppNakPduDeserializer.hNakPduSerializer.cppNakPduSerializer.hPduConfig.cppPduConfig.hPduHeaderIF.hPromptPduDeserializer.cppPromptPduDeserializer.hPromptPduSerializer.cppPromptPduSerializer.hVarLenField.cppVarLenField.h
tlv
container
ArrayList.hBinaryTree.hDynamicFIFO.hFIFO.hFIFOBase.hFixedArrayList.hFixedMap.hFixedOrderedMultimap.hHybridIterator.hIndexedRingMemoryArray.hPlacementFactory.hRingBufferBase.hSharedRingBuffer.cppSharedRingBuffer.hSimpleRingBuffer.cppSimpleRingBuffer.hSinglyLinkedList.hgroup.h
controller
coordinates
CoordinateTransformations.cppCoordinateTransformations.hJgm3Model.hSgp4Propagator.cppSgp4Propagator.h
datalinklayer
BCFrame.hCCSDSReturnValuesIF.hClcw.cppClcw.hClcwIF.hDataLinkLayer.cppDataLinkLayer.hFarm1StateIF.hFarm1StateLockout.cppFarm1StateLockout.hFarm1StateOpen.cppFarm1StateOpen.hFarm1StateWait.cppFarm1StateWait.hMapPacketExtraction.cppMapPacketExtraction.hMapPacketExtractionIF.hTcTransferFrame.cppTcTransferFrame.hTcTransferFrameLocal.cppTcTransferFrameLocal.hVirtualChannelReception.cppVirtualChannelReception.hVirtualChannelReceptionIF.h
datapool
DataSetIF.hHkSwitchHelper.cppHkSwitchHelper.hPoolDataSetBase.cppPoolDataSetBase.hPoolDataSetIF.hPoolEntry.cppPoolEntry.hPoolEntryIF.hPoolReadGuard.hPoolVarList.hPoolVariableIF.hReadCommitIF.hReadCommitIFAttorney.hSharedDataSetIF.h
datapoollocal.hdatapoollocal
AccessLocalPoolF.hHasLocalDataPoolIF.hLocalDataPoolManager.cppLocalDataPoolManager.hLocalDataSet.cppLocalDataSet.hLocalPoolDataSetBase.cppLocalPoolDataSetBase.hLocalPoolObjectBase.cppLocalPoolObjectBase.hLocalPoolVariable.hLocalPoolVector.hMarkChangedIF.hProvidesDataPoolSubscriptionIF.hSharedLocalDataSet.cppSharedLocalDataSet.hStaticLocalDataSet.h
internal
HasLocalDpIFManagerAttorney.cppHasLocalDpIFManagerAttorney.hHasLocalDpIFUserAttorney.cppHasLocalDpIFUserAttorney.hLocalDpManagerAttorney.hLocalPoolDataSetAttorney.h
localPoolDefinitions.hdevicehandlers
AcceptsDeviceResponsesIF.hAssemblyBase.cppAssemblyBase.hChildHandlerBase.cppChildHandlerBase.hChildHandlerFDIR.cppChildHandlerFDIR.hCookieIF.hDeviceCommunicationIF.hDeviceHandlerBase.cppDeviceHandlerBase.hDeviceHandlerFailureIsolation.cppDeviceHandlerFailureIsolation.hDeviceHandlerIF.hDeviceHandlerMessage.cppDeviceHandlerMessage.hDeviceHandlerThermalSet.hDeviceTmReportingWrapper.cppDeviceTmReportingWrapper.hHealthDevice.cppHealthDevice.h
events
Event.hEventManager.cppEventManager.hEventManagerIF.hEventMessage.cppEventMessage.hEventReportingProxyIF.h
eventmatching
EventIdRangeMatcher.cppEventIdRangeMatcher.hEventMatchTree.cppEventMatchTree.hEventRangeMatcherBase.hReporterRangeMatcher.cppReporterRangeMatcher.hSeverityRangeMatcher.cppSeverityRangeMatcher.heventmatching.h
fwSubsystemIdRanges.hfdir
ConfirmsFailuresIF.hEventCorrelation.cppEventCorrelation.hFailureIsolationBase.cppFailureIsolationBase.hFaultCounter.cppFaultCounter.h
globalfunctions
AsciiConverter.cppAsciiConverter.hCRC.cppCRC.hDleEncoder.cppDleEncoder.hPeriodicOperationDivider.cppPeriodicOperationDivider.hType.cppType.harrayprinter.cpparrayprinter.hbitutility.cppbitutility.hconstants.h
matching
math
sign.htimevalOperations.cpptimevalOperations.hhealth
HasHealthIF.hHealthHelper.cppHealthHelper.hHealthMessage.cppHealthMessage.hHealthTable.cppHealthTable.hHealthTableIF.hManagesHealthIF.h
housekeeping
AcceptsHkPacketsIF.hHousekeepingMessage.cppHousekeepingMessage.hHousekeepingPacketDownlink.hHousekeepingSetPacket.hHousekeepingSnapshot.hPeriodicHousekeepingHelper.cppPeriodicHousekeepingHelper.h
internalerror
ipc
CommandMessage.cppCommandMessage.hCommandMessageCleaner.cppCommandMessageCleaner.hCommandMessageIF.hFwMessageTypes.hMessageQueueIF.hMessageQueueMessage.cppMessageQueueMessage.hMessageQueueMessageIF.hMessageQueueSenderIF.hMutexFactory.hMutexGuard.hMutexIF.hQueueFactory.h
memory
AcceptsMemoryMessagesIF.hFileSystemArgsIF.hGenericFileSystemMessage.cppGenericFileSystemMessage.hHasFileSystemIF.hHasMemoryIF.hMemoryHelper.cppMemoryHelper.hMemoryMessage.cppMemoryMessage.h
modes
monitoring
AbsLimitMonitor.hHasMonitorsIF.hLimitMonitor.hLimitViolationReporter.cppLimitViolationReporter.hMonitorBase.hMonitorReporter.hMonitoringIF.hMonitoringMessage.cppMonitoringMessage.hMonitoringMessageContent.hReceivesMonitoringReportsIF.hTriplexMonitor.hTwoValueLimitMonitor.h
objectmanager
ObjectManager.cppObjectManager.hObjectManagerIF.hSystemObject.cppSystemObject.hSystemObjectIF.hframeworkObjects.h
osal
Endiness.hInternalErrorCodes.h
common
TcpIpBase.cppTcpIpBase.hTcpTmTcBridge.cppTcpTmTcBridge.hTcpTmTcServer.cppTcpTmTcServer.hUdpTcPollingTask.cppUdpTcPollingTask.hUdpTmTcBridge.cppUdpTmTcBridge.htcpipCommon.cpptcpipCommon.htcpipHelpers.h
freertos
BinSemaphUsingTask.cppBinSemaphUsingTask.hBinarySemaphore.cppBinarySemaphore.hClock.cppCountingSemaphUsingTask.cppCountingSemaphUsingTask.hCountingSemaphore.cppCountingSemaphore.hFixedTimeslotTask.cppFixedTimeslotTask.hFreeRTOSTaskIF.hMessageQueue.cppMessageQueue.hMutex.cppMutex.hMutexFactory.cppPeriodicTask.cppPeriodicTask.hQueueFactory.cppQueueMapManager.cppQueueMapManager.hSemaphoreFactory.cppTaskFactory.cppTaskManagement.cppTaskManagement.hTimekeeper.cppTimekeeper.h
host
Clock.cppFixedTimeslotTask.cppFixedTimeslotTask.hMessageQueue.cppMessageQueue.hMutex.cppMutex.hMutexFactory.cppPeriodicTask.cppPeriodicTask.hQueueFactory.cppQueueMapManager.cppQueueMapManager.hSemaphoreFactory.cppTaskFactory.cpptaskHelpers.cpptaskHelpers.h
linux
BinarySemaphore.cppBinarySemaphore.hClock.cppCountingSemaphore.cppCountingSemaphore.hFixedTimeslotTask.cppFixedTimeslotTask.hInternalErrorCodes.cppMessageQueue.cppMessageQueue.hMutex.cppMutex.hMutexFactory.cppPeriodicPosixTask.cppPeriodicPosixTask.hPosixThread.cppPosixThread.hQueueFactory.cppSemaphoreFactory.cppTaskFactory.cpptcpipHelpers.cppunixUtility.cppunixUtility.h
rtems
BinarySemaphore.cppBinarySemaphore.hClock.cppCpuUsage.cppCpuUsage.hFixedTimeslotTask.cppFixedTimeslotTask.hInitTask.cppInitTask.hInternalErrorCodes.cppMessageQueue.cppMessageQueue.hMutex.cppMutex.hMutexFactory.cppPeriodicTask.cppPeriodicTask.hQueueFactory.cppRTEMSTaskBase.cppRTEMSTaskBase.hRtemsBasic.hSemaphoreFactory.cppTaskFactory.cpp
windows
parameters
HasParametersIF.hParameterHelper.cppParameterHelper.hParameterMessage.cppParameterMessage.hParameterWrapper.cppParameterWrapper.hReceivesParameterMessagesIF.h
power
Fuse.cppFuse.hPowerComponent.cppPowerComponent.hPowerComponentIF.hPowerSensor.cppPowerSensor.hPowerSwitchIF.hPowerSwitcher.cppPowerSwitcher.h
pus
CService200ModeCommanding.cppCService200ModeCommanding.hCService201HealthCommanding.cppCService201HealthCommanding.hService17Test.cppService17Test.hService1TelecommandVerification.cppService1TelecommandVerification.hService20ParameterManagement.cppService20ParameterManagement.hService2DeviceAccess.cppService2DeviceAccess.hService3Housekeeping.cppService3Housekeeping.hService5EventReporting.cppService5EventReporting.hService8FunctionManagement.cppService8FunctionManagement.hService9TimeManagement.cppService9TimeManagement.h
servicepackets
returnvalues
rmap
RMAP.cppRMAP.hRMAPChannelIF.hRMAPCookie.cppRMAPCookie.hRmapDeviceCommunicationIF.cppRmapDeviceCommunicationIF.hrmapStructs.h
serialize.hserialize
EndianConverter.hSerialArrayListAdapter.hSerialBufferAdapter.cppSerialBufferAdapter.hSerialFixedArrayListAdapter.hSerialLinkedListAdapter.hSerializeAdapter.hSerializeElement.hSerializeIF.h
serviceinterface
ServiceInterfaceBuffer.cppServiceInterfaceBuffer.hServiceInterfacePrinter.cppServiceInterfacePrinter.hServiceInterfaceStream.cppServiceInterfaceStream.hserviceInterfaceDefintions.h
storagemanager
ConstStorageAccessor.cppConstStorageAccessor.hLocalPool.cppLocalPool.hPoolManager.cppPoolManager.hStorageAccessor.cppStorageAccessor.hStorageManagerIF.hstoreAddress.h
subsystem
tasks
ExecutableObjectIF.hFixedSequenceSlot.cppFixedSequenceSlot.hFixedSlotSequence.cppFixedSlotSequence.hFixedTimeslotTaskIF.hPeriodicTaskIF.hSemaphoreFactory.hSemaphoreIF.hTaskFactory.hTypedef.h
tcdistribution
CCSDSDistributor.cppCCSDSDistributor.hCCSDSDistributorIF.hCFDPDistributor.cppCFDPDistributor.hCFDPDistributorIF.hPUSDistributor.cppPUSDistributor.hPUSDistributorIF.hTcDistributor.cppTcDistributor.hTcPacketCheckCFDP.cppTcPacketCheckCFDP.hTcPacketCheckIF.hTcPacketCheckPUS.cppTcPacketCheckPUS.h
thermal
AbstractTemperatureSensor.cppAbstractTemperatureSensor.hAcceptsThermalMessagesIF.hHeater.cppHeater.hRedundantHeater.cppRedundantHeater.hTemperatureSensor.hThermalComponent.cppThermalComponent.hThermalComponentCore.cppThermalComponentCore.hThermalComponentIF.hThermalModule.cppThermalModule.hThermalModuleIF.hThermalMonitorReporter.cppThermalMonitorReporter.h
timemanager
CCSDSTime.cppCCSDSTime.hClock.hClockCommon.cppCountdown.cppCountdown.hReceivesTimeInfoIF.hStopwatch.cppStopwatch.hTimeMessage.cppTimeMessage.hTimeStamper.cppTimeStamper.hTimeStamperIF.h
tmstorage
tmtcpacket
RedirectableDataPointerIF.hSpacePacket.cppSpacePacket.hSpacePacketBase.cppSpacePacketBase.hccsds_header.h
cfdp
packetmatcher
pus
tmtcservices
AcceptsTelecommandsIF.hAcceptsTelemetryIF.hAcceptsVerifyMessageIF.hCommandingServiceBase.cppCommandingServiceBase.hPusServiceBase.cppPusServiceBase.hPusVerificationReport.cppPusVerificationReport.hSourceSequenceCounter.hSpacePacketParser.cppSpacePacketParser.hTmTcBridge.cppTmTcBridge.hTmTcMessage.cppTmTcMessage.hVerificationCodes.hVerificationReporter.cppVerificationReporter.h
tests/src/fsfw_tests
integration
assemblies
controller
devices
TestCookie.cppTestCookie.hTestDeviceHandler.cppTestDeviceHandler.hTestEchoComIF.cppTestEchoComIF.h
devicedefinitions
task
internal
InternalUnitTester.cppInternalUnitTester.hUnittDefinitions.cppUnittDefinitions.h
globalfunctions
osal
serialize
unit
CatchDefinitions.cppCatchDefinitions.hCatchFactory.cppCatchFactory.hCatchRunner.cppCatchRunner.hCatchSetup.cpp
action
cfdp
testAckPdu.cpptestCfdp.cpptestEofPdu.cpptestFileData.cpptestFinishedPdu.cpptestKeepAlivePdu.cpptestMetadataPdu.cpptestNakPdu.cpptestPromptPdu.cpptestTlvsLvs.cpp
container
RingBufferTest.cppTestArrayList.cppTestDynamicFifo.cppTestFifo.cppTestFixedArrayList.cppTestFixedMap.cppTestFixedOrderedMultimap.cppTestPlacementFactory.cpp
datapoollocal
DataSetTest.cppLocalPoolManagerTest.cppLocalPoolOwnerBase.cppLocalPoolOwnerBase.hLocalPoolVariableTest.cppLocalPoolVectorTest.cpp
globalfunctions
hal
mocks
osal
printChar.cppprintChar.hserialize
storagemanager
testcfg
devices
events
ipc
objects
pollingsequence
returnvalues
tmtc
testtemplate
timemanager
tmtcpacket
@ -1,173 +1,166 @@
|
||||
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||
|
||||
#include <fsfw/container/FixedMap.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "fsfw_tests/unit/CatchDefinitions.h"
|
||||
|
||||
template class FixedMap<unsigned int, unsigned short>;
|
||||
|
||||
TEST_CASE( "FixedMap Tests", "[TestFixedMap]") {
|
||||
INFO("FixedMap Tests");
|
||||
TEST_CASE("FixedMap Tests", "[TestFixedMap]") {
|
||||
INFO("FixedMap Tests");
|
||||
|
||||
FixedMap<unsigned int, unsigned short> map(30);
|
||||
REQUIRE(map.size() == 0);
|
||||
REQUIRE(map.maxSize() == 30);
|
||||
REQUIRE(map.getSerializedSize() == sizeof(uint32_t));
|
||||
REQUIRE(map.empty());
|
||||
REQUIRE(not map.full());
|
||||
FixedMap<unsigned int, unsigned short> map(30);
|
||||
REQUIRE(map.size() == 0);
|
||||
REQUIRE(map.maxSize() == 30);
|
||||
REQUIRE(map.getSerializedSize() == sizeof(uint32_t));
|
||||
REQUIRE(map.empty());
|
||||
REQUIRE(not map.full());
|
||||
|
||||
SECTION("Fill and erase"){
|
||||
for (uint16_t i=0;i<30;i++){
|
||||
REQUIRE(map.insert(std::make_pair(i, i+1))== static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.exists(i) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.find(i)->second==i+1);
|
||||
REQUIRE(not map.empty());
|
||||
}
|
||||
REQUIRE(map.insert(0, 0) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_ALREADY_EXISTS));
|
||||
REQUIRE(map.insert(31, 0) == static_cast<int>(FixedMap<uint32_t, uint16_t>::MAP_FULL));
|
||||
REQUIRE(map.exists(31) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.size() == 30);
|
||||
REQUIRE(map.full());
|
||||
{
|
||||
uint16_t* ptr;
|
||||
REQUIRE(map.find(5,&ptr) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(*ptr == 6);
|
||||
REQUIRE(*(map.findValue(6)) == 7);
|
||||
REQUIRE(map.find(31,&ptr) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
}
|
||||
SECTION("Fill and erase") {
|
||||
for (uint16_t i = 0; i < 30; i++) {
|
||||
REQUIRE(map.insert(std::make_pair(i, i + 1)) ==
|
||||
static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.exists(i) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.find(i)->second == i + 1);
|
||||
REQUIRE(not map.empty());
|
||||
}
|
||||
REQUIRE(map.insert(0, 0) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_ALREADY_EXISTS));
|
||||
REQUIRE(map.insert(31, 0) == static_cast<int>(FixedMap<uint32_t, uint16_t>::MAP_FULL));
|
||||
REQUIRE(map.exists(31) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.size() == 30);
|
||||
REQUIRE(map.full());
|
||||
{
|
||||
uint16_t* ptr;
|
||||
REQUIRE(map.find(5, &ptr) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(*ptr == 6);
|
||||
REQUIRE(*(map.findValue(6)) == 7);
|
||||
REQUIRE(map.find(31, &ptr) ==
|
||||
static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
}
|
||||
|
||||
REQUIRE(map.getSerializedSize() == (sizeof(uint32_t)+ 30*(sizeof(uint32_t) + sizeof(uint16_t))));
|
||||
REQUIRE(map.erase(2) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.erase(31) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.exists(2) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.size() == 29);
|
||||
REQUIRE(map.getSerializedSize() ==
|
||||
(sizeof(uint32_t) + 30 * (sizeof(uint32_t) + sizeof(uint16_t))));
|
||||
REQUIRE(map.erase(2) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.erase(31) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.exists(2) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.size() == 29);
|
||||
|
||||
for (auto element: map){
|
||||
if (element.first == 5){
|
||||
REQUIRE(element.second == 6);
|
||||
}
|
||||
}
|
||||
for (auto element : map) {
|
||||
if (element.first == 5) {
|
||||
REQUIRE(element.second == 6);
|
||||
}
|
||||
}
|
||||
|
||||
for (FixedMap<uint32_t, uint16_t>::Iterator it = map.begin(); it != map.end(); it++){
|
||||
REQUIRE(it->second == it->first + 1);
|
||||
REQUIRE((*it).second == (*it).first + 1);
|
||||
it->second = it->second + 1;
|
||||
REQUIRE(it->second == it->first + 2);
|
||||
}
|
||||
for (FixedMap<uint32_t, uint16_t>::Iterator it = map.begin(); it != map.end(); it++) {
|
||||
REQUIRE(it->second == it->first + 1);
|
||||
REQUIRE((*it).second == (*it).first + 1);
|
||||
it->second = it->second + 1;
|
||||
REQUIRE(it->second == it->first + 2);
|
||||
}
|
||||
|
||||
for (FixedMap<uint32_t, uint16_t>::Iterator it = map.begin(); it != map.end(); it++){
|
||||
REQUIRE(map.erase(&it) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
}
|
||||
for (FixedMap<uint32_t, uint16_t>::Iterator it = map.begin(); it != map.end(); it++) {
|
||||
REQUIRE(map.erase(&it) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
}
|
||||
|
||||
REQUIRE(map.size() == 0);
|
||||
REQUIRE(map.size() == 0);
|
||||
|
||||
for (FixedMap<uint32_t, uint16_t>::Iterator it = map.begin(); it != map.end(); it++){
|
||||
// This line should never executed if begin and end is correct
|
||||
FAIL("Should never be reached, Iterators invalid");
|
||||
}
|
||||
};
|
||||
for (FixedMap<uint32_t, uint16_t>::Iterator it = map.begin(); it != map.end(); it++) {
|
||||
// This line should never executed if begin and end is correct
|
||||
FAIL("Should never be reached, Iterators invalid");
|
||||
}
|
||||
};
|
||||
|
||||
SECTION("Insert variants"){
|
||||
FixedMap<uint32_t, uint16_t>::Iterator it = map.end();
|
||||
REQUIRE(map.insert(36, 37, &it) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(it->first == 36);
|
||||
REQUIRE(it->second == 37);
|
||||
REQUIRE(map.size() == 1);
|
||||
REQUIRE(map.insert(37, 38, nullptr) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.find(37)->second == 38);
|
||||
REQUIRE(map.size() == 2);
|
||||
REQUIRE(map.insert(37, 24, nullptr) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_ALREADY_EXISTS));
|
||||
REQUIRE(map.find(37)->second != 24);
|
||||
REQUIRE(map.size() == 2);
|
||||
};
|
||||
SECTION("Serialize and DeSerialize") {
|
||||
REQUIRE(map.insert(36, 37, nullptr) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.insert(37, 38, nullptr) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
uint8_t buffer[sizeof(uint32_t)
|
||||
+ 2 * (sizeof(uint32_t) + sizeof(uint16_t))];
|
||||
REQUIRE(
|
||||
map.getSerializedSize()
|
||||
== (sizeof(uint32_t)
|
||||
+ 2 * (sizeof(uint32_t) + sizeof(uint16_t))));
|
||||
uint8_t *loc_ptr = buffer;
|
||||
size_t size = 0;
|
||||
REQUIRE(
|
||||
map.serialize(&loc_ptr, &size, 10, SerializeIF::Endianness::BIG)
|
||||
== static_cast<int>(SerializeIF::BUFFER_TOO_SHORT));
|
||||
loc_ptr = buffer;
|
||||
size = 0;
|
||||
REQUIRE(
|
||||
map.serialize(&loc_ptr, &size,
|
||||
sizeof(uint32_t)
|
||||
+ 2 * (sizeof(uint32_t) + sizeof(uint16_t)),
|
||||
SerializeIF::Endianness::BIG)
|
||||
== static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(size == 16);
|
||||
SECTION("Insert variants") {
|
||||
FixedMap<uint32_t, uint16_t>::Iterator it = map.end();
|
||||
REQUIRE(map.insert(36, 37, &it) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(it->first == 36);
|
||||
REQUIRE(it->second == 37);
|
||||
REQUIRE(map.size() == 1);
|
||||
REQUIRE(map.insert(37, 38, nullptr) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.find(37)->second == 38);
|
||||
REQUIRE(map.size() == 2);
|
||||
REQUIRE(map.insert(37, 24, nullptr) ==
|
||||
static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_ALREADY_EXISTS));
|
||||
REQUIRE(map.find(37)->second != 24);
|
||||
REQUIRE(map.size() == 2);
|
||||
};
|
||||
SECTION("Serialize and DeSerialize") {
|
||||
REQUIRE(map.insert(36, 37, nullptr) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.insert(37, 38, nullptr) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
uint8_t buffer[sizeof(uint32_t) + 2 * (sizeof(uint32_t) + sizeof(uint16_t))];
|
||||
REQUIRE(map.getSerializedSize() ==
|
||||
(sizeof(uint32_t) + 2 * (sizeof(uint32_t) + sizeof(uint16_t))));
|
||||
uint8_t* loc_ptr = buffer;
|
||||
size_t size = 0;
|
||||
REQUIRE(map.serialize(&loc_ptr, &size, 10, SerializeIF::Endianness::BIG) ==
|
||||
static_cast<int>(SerializeIF::BUFFER_TOO_SHORT));
|
||||
loc_ptr = buffer;
|
||||
size = 0;
|
||||
REQUIRE(map.serialize(
|
||||
&loc_ptr, &size, sizeof(uint32_t) + 2 * (sizeof(uint32_t) + sizeof(uint16_t)),
|
||||
SerializeIF::Endianness::BIG) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(size == 16);
|
||||
|
||||
uint32_t internal_size = 0;
|
||||
const uint8_t *ptr2 = buffer;
|
||||
REQUIRE(
|
||||
SerializeAdapter::deSerialize(&internal_size, &ptr2, &size,
|
||||
SerializeIF::Endianness::BIG)
|
||||
== static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(internal_size == 2);
|
||||
for (uint8_t i = 36; i < 38; i++) {
|
||||
uint32_t first_element = 0;
|
||||
REQUIRE(
|
||||
SerializeAdapter::deSerialize(&first_element, &ptr2, &size,
|
||||
SerializeIF::Endianness::BIG)
|
||||
== static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(first_element == i);
|
||||
uint16_t second_element = 0;
|
||||
REQUIRE(
|
||||
SerializeAdapter::deSerialize(&second_element, &ptr2, &size,
|
||||
SerializeIF::Endianness::BIG)
|
||||
== static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(second_element == i + 1);
|
||||
}
|
||||
REQUIRE(size == 0);
|
||||
map.clear();
|
||||
const uint8_t* constPtr = buffer;
|
||||
size = 16;
|
||||
REQUIRE(map.size() == 0);
|
||||
REQUIRE(map.deSerialize(&constPtr, &size,
|
||||
SerializeIF::Endianness::BIG) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.size() == 2);
|
||||
REQUIRE(map.find(36)->second == 37);
|
||||
for(auto& element: map){
|
||||
REQUIRE((element.first+1) == element.second);
|
||||
}
|
||||
};
|
||||
uint32_t internal_size = 0;
|
||||
const uint8_t* ptr2 = buffer;
|
||||
REQUIRE(
|
||||
SerializeAdapter::deSerialize(&internal_size, &ptr2, &size, SerializeIF::Endianness::BIG) ==
|
||||
static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(internal_size == 2);
|
||||
for (uint8_t i = 36; i < 38; i++) {
|
||||
uint32_t first_element = 0;
|
||||
REQUIRE(SerializeAdapter::deSerialize(&first_element, &ptr2, &size,
|
||||
SerializeIF::Endianness::BIG) ==
|
||||
static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(first_element == i);
|
||||
uint16_t second_element = 0;
|
||||
REQUIRE(SerializeAdapter::deSerialize(&second_element, &ptr2, &size,
|
||||
SerializeIF::Endianness::BIG) ==
|
||||
static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(second_element == i + 1);
|
||||
}
|
||||
REQUIRE(size == 0);
|
||||
map.clear();
|
||||
const uint8_t* constPtr = buffer;
|
||||
size = 16;
|
||||
REQUIRE(map.size() == 0);
|
||||
REQUIRE(map.deSerialize(&constPtr, &size, SerializeIF::Endianness::BIG) ==
|
||||
static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.size() == 2);
|
||||
REQUIRE(map.find(36)->second == 37);
|
||||
for (auto& element : map) {
|
||||
REQUIRE((element.first + 1) == element.second);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
SECTION("Failed erase and deSerialize"){
|
||||
FixedMap<uint32_t, uint16_t>::Iterator it;
|
||||
std::pair<uint32_t, uint16_t> pair = std::make_pair(44, 43);
|
||||
it = FixedMap<uint32_t, uint16_t>::Iterator(&pair);
|
||||
REQUIRE(map.erase(&it) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.find(45) == map.end());
|
||||
size_t toLargeMap = 100;
|
||||
const uint8_t* ptr = reinterpret_cast<uint8_t*>(&toLargeMap);
|
||||
size_t size = sizeof(size_t);
|
||||
REQUIRE(map.deSerialize(&ptr, &size, SerializeIF::Endianness::BIG) ==
|
||||
static_cast<int>(SerializeIF::TOO_MANY_ELEMENTS));
|
||||
};
|
||||
SECTION("Little Endianess"){
|
||||
map.clear();
|
||||
map.insert(10,20, nullptr);
|
||||
uint8_t newBuffer[sizeof(uint32_t)+ 1*(sizeof(uint32_t) + sizeof(uint16_t))];
|
||||
uint8_t* ptr = newBuffer;
|
||||
size_t size = 0;
|
||||
size_t max_size = sizeof(uint32_t)+ 1*(sizeof(uint32_t) + sizeof(uint16_t));
|
||||
REQUIRE(map.serialize(&ptr, &size, max_size,
|
||||
SerializeIF::Endianness::LITTLE) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
map.clear();
|
||||
REQUIRE(map.size()==0);
|
||||
const uint8_t* ptr2 = newBuffer;
|
||||
REQUIRE(map.deSerialize(&ptr2, &size,
|
||||
SerializeIF::Endianness::LITTLE) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.size()==1);
|
||||
REQUIRE(map.find(10)->second == 20);
|
||||
};
|
||||
SECTION("Failed erase and deSerialize") {
|
||||
FixedMap<uint32_t, uint16_t>::Iterator it;
|
||||
std::pair<uint32_t, uint16_t> pair = std::make_pair(44, 43);
|
||||
it = FixedMap<uint32_t, uint16_t>::Iterator(&pair);
|
||||
REQUIRE(map.erase(&it) == static_cast<int>(FixedMap<uint32_t, uint16_t>::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.find(45) == map.end());
|
||||
size_t toLargeMap = 100;
|
||||
const uint8_t* ptr = reinterpret_cast<uint8_t*>(&toLargeMap);
|
||||
size_t size = sizeof(size_t);
|
||||
REQUIRE(map.deSerialize(&ptr, &size, SerializeIF::Endianness::BIG) ==
|
||||
static_cast<int>(SerializeIF::TOO_MANY_ELEMENTS));
|
||||
};
|
||||
SECTION("Little Endianess") {
|
||||
map.clear();
|
||||
map.insert(10, 20, nullptr);
|
||||
uint8_t newBuffer[sizeof(uint32_t) + 1 * (sizeof(uint32_t) + sizeof(uint16_t))];
|
||||
uint8_t* ptr = newBuffer;
|
||||
size_t size = 0;
|
||||
size_t max_size = sizeof(uint32_t) + 1 * (sizeof(uint32_t) + sizeof(uint16_t));
|
||||
REQUIRE(map.serialize(&ptr, &size, max_size, SerializeIF::Endianness::LITTLE) ==
|
||||
static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
map.clear();
|
||||
REQUIRE(map.size() == 0);
|
||||
const uint8_t* ptr2 = newBuffer;
|
||||
REQUIRE(map.deSerialize(&ptr2, &size, SerializeIF::Endianness::LITTLE) ==
|
||||
static_cast<int>(HasReturnvaluesIF::RETURN_OK));
|
||||
REQUIRE(map.size() == 1);
|
||||
REQUIRE(map.find(10)->second == 20);
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user