added some more basic tests

This commit is contained in:
Robin Müller 2022-08-17 17:09:39 +02:00
parent 0bb82e0da2
commit 6930656d4e
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
5 changed files with 26 additions and 7 deletions

View File

@ -8,7 +8,7 @@ namespace cfdp {
class RemoteConfigTableIF {
public:
virtual ~RemoteConfigTableIF() = default;
virtual bool getRemoteCfg(EntityId remoteId, RemoteEntityCfg* cfg) = 0;
virtual bool getRemoteCfg(const cfdp::EntityId& remoteId, cfdp::RemoteEntityCfg** cfg) = 0;
};
} // namespace cfdp

View File

@ -1,7 +1,9 @@
#include <catch2/catch_test_macros.hpp>
#include "fsfw/cfdp.h"
#include "mocks/FilesystemMock.h"
#include "mocks/cfdp/FaultHandlerMock.h"
#include "mocks/cfdp/RemoteConfigTableMock.h"
#include "mocks/cfdp/UserMock.h"
TEST_CASE("CFDP Dest Handler", "[cfdp]") {
@ -9,7 +11,10 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
EntityId localId = EntityId(UnsignedByteField<uint16_t>(2));
auto fhMock = FaultHandlerMock();
auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock);
// auto userMock = UserMock();
auto fsMock = FilesystemMock();
auto userMock = UserMock(fsMock);
auto remoteCfgTableMock = RemoteConfigTableMock();
auto destHandler = DestHandler(localEntityCfg, userMock, remoteCfgTableMock);
SECTION("State") {}
}

View File

@ -1,6 +1,15 @@
#include "RemoteConfigTableMock.h"
bool cfdp::RemoteConfigTableMock::getRemoteCfg(cfdp::EntityId remoteId,
cfdp::RemoteEntityCfg *cfg) {
return false;
void cfdp::RemoteConfigTableMock::addRemoteConfig(const cfdp::RemoteEntityCfg& cfg) {
remoteCfgTable.emplace(cfg.remoteId, cfg);
}
bool cfdp::RemoteConfigTableMock::getRemoteCfg(const cfdp::EntityId& remoteId,
cfdp::RemoteEntityCfg** cfg) {
auto iter = remoteCfgTable.find(remoteId);
if (iter == remoteCfgTable.end()) {
return false;
}
*cfg = &iter->second;
return true;
}

View File

@ -1,13 +1,18 @@
#ifndef FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H
#define FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H
#include <map>
#include "fsfw/cfdp/handler/RemoteConfigTableIF.h"
namespace cfdp {
class RemoteConfigTableMock : public RemoteConfigTableIF {
public:
bool getRemoteCfg(EntityId remoteId, RemoteEntityCfg *cfg) override;
void addRemoteConfig(const RemoteEntityCfg& cfg);
bool getRemoteCfg(const cfdp::EntityId& remoteId, cfdp::RemoteEntityCfg** cfg) override;
std::map<EntityId, RemoteEntityCfg> remoteCfgTable;
};
} // namespace cfdp

View File

@ -5,9 +5,9 @@
namespace cfdp {
class UserMock : public UserBase {
public:
explicit UserMock(HasFileSystemIF& vfs);
public:
void transactionIndication(TransactionId id) override;
void eofSentIndication(TransactionId id) override;
void abandonedIndication(TransactionId id, ConditionCode code, size_t progress) override;