2020-12-28 01:17:03 +01:00
|
|
|
#include <fsfw/container/FixedArrayList.h>
|
2022-08-16 12:48:22 +02:00
|
|
|
#include <fsfw/returnvalues/returnvalue.h>
|
2020-10-29 12:23:27 +01:00
|
|
|
|
2020-12-27 14:14:38 +01:00
|
|
|
#include <catch2/catch_test_macros.hpp>
|
2020-10-20 17:11:23 +02:00
|
|
|
|
2022-07-18 11:58:55 +02:00
|
|
|
#include "CatchDefinitions.h"
|
2020-10-20 17:11:23 +02:00
|
|
|
|
2022-08-08 12:35:58 +02:00
|
|
|
TEST_CASE("FixedArrayList Tests", "[containers]") {
|
2022-02-02 10:29:30 +01:00
|
|
|
INFO("FixedArrayList Tests");
|
|
|
|
using testList = FixedArrayList<uint32_t, 260, uint16_t>;
|
|
|
|
testList list;
|
|
|
|
REQUIRE(list.size == 0);
|
2022-08-15 20:28:16 +02:00
|
|
|
REQUIRE(list.insert(10) == static_cast<int>(returnvalue::OK));
|
2022-02-02 10:29:30 +01:00
|
|
|
REQUIRE(list.size == 1);
|
|
|
|
REQUIRE(list.maxSize() == 260);
|
|
|
|
SECTION("Copy Constructor") {
|
|
|
|
testList list2(list);
|
|
|
|
REQUIRE(list2.size == 1);
|
|
|
|
REQUIRE(list2[0] == 10);
|
|
|
|
REQUIRE(list.maxSize() == 260);
|
|
|
|
};
|
|
|
|
SECTION("Assignment copy") {
|
|
|
|
testList list2;
|
|
|
|
REQUIRE(list2.size == 0);
|
|
|
|
list2 = list;
|
|
|
|
REQUIRE(list2.size == 1);
|
|
|
|
REQUIRE(list2[0] == 10);
|
|
|
|
REQUIRE(list.maxSize() == 260);
|
|
|
|
};
|
|
|
|
SECTION("Fill") {
|
|
|
|
for (auto i = 1; i < 260; i++) {
|
2022-08-15 20:28:16 +02:00
|
|
|
REQUIRE(list.insert(i) == static_cast<int>(returnvalue::OK));
|
2022-02-02 10:29:30 +01:00
|
|
|
}
|
2022-11-10 16:11:05 +01:00
|
|
|
REQUIRE(list.insert(260) == static_cast<int>(containers::LIST_FULL));
|
2022-02-02 10:29:30 +01:00
|
|
|
list.clear();
|
|
|
|
REQUIRE(list.size == 0);
|
|
|
|
}
|
2020-10-20 17:11:23 +02:00
|
|
|
}
|