fix unittests
This commit is contained in:
parent
194b3e100a
commit
6ca1a5c796
@ -3,13 +3,12 @@
|
||||
|
||||
#include "fsfw/retval.h"
|
||||
|
||||
using namespace returnvalue;
|
||||
namespace containers {
|
||||
static const ReturnValue_t KEY_ALREADY_EXISTS = makeCode(CLASS_ID::FIXED_MAP, 0x01);
|
||||
static const ReturnValue_t MAP_FULL = makeCode(CLASS_ID::FIXED_MAP, 0x02);
|
||||
static const ReturnValue_t KEY_DOES_NOT_EXIST = makeCode(CLASS_ID::FIXED_MAP, 0x03);
|
||||
static const ReturnValue_t KEY_ALREADY_EXISTS = returnvalue::makeCode(CLASS_ID::FIXED_MAP, 0x01);
|
||||
static const ReturnValue_t MAP_FULL = returnvalue::makeCode(CLASS_ID::FIXED_MAP, 0x02);
|
||||
static const ReturnValue_t KEY_DOES_NOT_EXIST = returnvalue::makeCode(CLASS_ID::FIXED_MAP, 0x03);
|
||||
|
||||
static const ReturnValue_t LIST_FULL = makeCode(CLASS_ID::ARRAY_LIST, 0x01);
|
||||
static const ReturnValue_t LIST_FULL = returnvalue::makeCode(CLASS_ID::ARRAY_LIST, 0x01);
|
||||
} // namespace containers
|
||||
|
||||
#endif /* FSFW_CONTAINER_DEFINITIONS_H_ */
|
||||
|
@ -22,7 +22,9 @@ UioMapper::UioMapper(std::string uioFile, int mapNum) : mapNum(mapNum) {
|
||||
if (res) {
|
||||
this->uioFile = res;
|
||||
} else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Could not resolve real path of UIO file " << uioFile << std::endl;
|
||||
#endif
|
||||
}
|
||||
free(res);
|
||||
} else {
|
||||
|
@ -43,7 +43,7 @@ TEST_CASE("Array List", "[containers]") {
|
||||
for (auto i = 0; i < 20; i++) {
|
||||
REQUIRE(list.insert(i) == static_cast<int>(returnvalue::OK));
|
||||
}
|
||||
REQUIRE(list.insert(20) == static_cast<int>(ArrayList<uint16_t>::FULL));
|
||||
REQUIRE(list.insert(20) == static_cast<int>(containers::LIST_FULL));
|
||||
ArrayList<uint16_t>::Iterator it = list.begin();
|
||||
REQUIRE((*it) == 0);
|
||||
it++;
|
||||
|
@ -31,7 +31,7 @@ TEST_CASE("FixedArrayList Tests", "[containers]") {
|
||||
for (auto i = 1; i < 260; i++) {
|
||||
REQUIRE(list.insert(i) == static_cast<int>(returnvalue::OK));
|
||||
}
|
||||
REQUIRE(list.insert(260) == static_cast<int>(ArrayList<uint32_t, uint16_t>::FULL));
|
||||
REQUIRE(list.insert(260) == static_cast<int>(containers::LIST_FULL));
|
||||
list.clear();
|
||||
REQUIRE(list.size == 0);
|
||||
}
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
template class FixedMap<unsigned int, unsigned short>;
|
||||
|
||||
using namespace returnvalue;
|
||||
|
||||
TEST_CASE("FixedMap Tests", "[containers]") {
|
||||
INFO("FixedMap Tests");
|
||||
|
||||
@ -24,9 +26,9 @@ TEST_CASE("FixedMap Tests", "[containers]") {
|
||||
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.insert(0, 0) == static_cast<int>(containers::KEY_ALREADY_EXISTS));
|
||||
REQUIRE(map.insert(31, 0) == static_cast<int>(containers::MAP_FULL));
|
||||
REQUIRE(map.exists(31) == static_cast<int>(containers::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.size() == 30);
|
||||
REQUIRE(map.full());
|
||||
{
|
||||
@ -35,14 +37,14 @@ TEST_CASE("FixedMap Tests", "[containers]") {
|
||||
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));
|
||||
static_cast<int>(containers::KEY_DOES_NOT_EXIST));
|
||||
}
|
||||
|
||||
REQUIRE(map.getSerializedSize() ==
|
||||
(sizeof(uint32_t) + 30 * (sizeof(uint32_t) + sizeof(uint16_t))));
|
||||
REQUIRE(map.erase(2) == static_cast<int>(returnvalue::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.erase(31) == static_cast<int>(containers::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.exists(2) == static_cast<int>(containers::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.size() == 29);
|
||||
|
||||
for (auto element : map) {
|
||||
@ -80,7 +82,7 @@ TEST_CASE("FixedMap Tests", "[containers]") {
|
||||
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));
|
||||
static_cast<int>(containers::KEY_ALREADY_EXISTS));
|
||||
REQUIRE(map.find(37)->second != 24);
|
||||
REQUIRE(map.size() == 2);
|
||||
};
|
||||
@ -137,7 +139,7 @@ TEST_CASE("FixedMap Tests", "[containers]") {
|
||||
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.erase(&it) == static_cast<int>(containers::KEY_DOES_NOT_EXIST));
|
||||
REQUIRE(map.find(45) == map.end());
|
||||
size_t toLargeMap = 100;
|
||||
const uint8_t* ptr = reinterpret_cast<uint8_t*>(&toLargeMap);
|
||||
|
@ -6,7 +6,7 @@ AcceptsTmMock::AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToR
|
||||
AcceptsTmMock::AcceptsTmMock(MessageQueueId_t queueToReturn)
|
||||
: SystemObject(objects::NO_OBJECT, false), returnedQueue(queueToReturn) {}
|
||||
|
||||
MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) {
|
||||
MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) const {
|
||||
return returnedQueue;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ class AcceptsTmMock : public SystemObject, public AcceptsTelemetryIF {
|
||||
AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToReturn);
|
||||
explicit AcceptsTmMock(MessageQueueId_t queueToReturn);
|
||||
|
||||
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override;
|
||||
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override;
|
||||
const char* getName() const override;
|
||||
|
||||
MessageQueueId_t returnedQueue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user