2020-05-31 14:37:49 +00:00
|
|
|
#ifdef TESTS_BUILD
|
|
|
|
#include "../extern/catch.hpp"
|
|
|
|
#include "../src/Memory/UniquePtrList.hpp"
|
|
|
|
using namespace ArbUt;
|
|
|
|
|
2020-05-31 14:40:33 +00:00
|
|
|
TEST_CASE("Create Unique Ptr list, append") {
|
2020-05-31 14:37:49 +00:00
|
|
|
auto ls = UniquePtrList<uint32_t>();
|
2020-05-31 14:40:33 +00:00
|
|
|
auto v1 = new uint32_t(100);
|
|
|
|
auto v2 = new uint32_t(5000);
|
2020-05-31 14:37:49 +00:00
|
|
|
ls.Append(v1);
|
|
|
|
ls.Append(v2);
|
|
|
|
}
|
|
|
|
|
2020-05-31 14:40:33 +00:00
|
|
|
TEST_CASE("Create Unique Ptr list, append, retrieve") {
|
2020-05-31 14:37:49 +00:00
|
|
|
auto ls = UniquePtrList<uint32_t>();
|
2020-05-31 14:40:33 +00:00
|
|
|
auto v1 = new uint32_t(100);
|
|
|
|
auto v2 = new uint32_t(5000);
|
2020-05-31 14:37:49 +00:00
|
|
|
ls.Append(v1);
|
|
|
|
ls.Append(v2);
|
|
|
|
REQUIRE(ls.Count() == 2);
|
|
|
|
CHECK(ls.At(0) == v1);
|
|
|
|
CHECK(ls.At(1) == v2);
|
|
|
|
CHECK(ls[0] == v1);
|
|
|
|
CHECK(ls[1] == v2);
|
|
|
|
}
|
|
|
|
|
2020-05-31 14:40:33 +00:00
|
|
|
TEST_CASE("Create Unique Ptr list, append, iterate") {
|
2020-05-31 14:37:49 +00:00
|
|
|
auto ls = UniquePtrList<uint32_t>();
|
2020-05-31 14:40:33 +00:00
|
|
|
auto v1 = new uint32_t(100);
|
|
|
|
auto v2 = new uint32_t(5000);
|
2020-05-31 14:37:49 +00:00
|
|
|
ls.Append(v1);
|
|
|
|
ls.Append(v2);
|
|
|
|
REQUIRE(ls.Count() == 2);
|
|
|
|
auto i = 0;
|
2020-05-31 14:40:33 +00:00
|
|
|
for (const auto& v : ls) {
|
|
|
|
if (i == 0)
|
|
|
|
CHECK(v == v1);
|
|
|
|
else if (i == 1)
|
|
|
|
CHECK(v == v2);
|
2020-05-31 14:37:49 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|