#ifdef TESTS_BUILD
#include "../extern/doctest.hpp"
#include "../src/Memory/__UniquePtrList.hpp"
using namespace ArbUt;

TEST_CASE("Create Unique Ptr list, append") {
    auto ls = UniquePtrList<uint32_t>();
    auto v1 = new uint32_t(100);
    auto v2 = new uint32_t(5000);
    ls.Append(v1);
    ls.Append(v2);
}

TEST_CASE("Create Unique Ptr list, append, retrieve") {
    auto ls = UniquePtrList<uint32_t>();
    auto v1 = new uint32_t(100);
    auto v2 = new uint32_t(5000);
    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);
}

TEST_CASE("Create Unique Ptr list, append, iterate") {
    auto ls = UniquePtrList<uint32_t>();
    auto v1 = new uint32_t(100);
    auto v2 = new uint32_t(5000);
    ls.Append(v1);
    ls.Append(v2);
    REQUIRE(ls.Count() == 2);
    auto i = 0;
    for (const auto& v : ls) {
        if (i == 0)
            CHECK(v == v1);
        else if (i == 1)
            CHECK(v == v2);
        i++;
    }
}

TEST_CASE("Test unique ptr list out of bounds") {
    auto ls = UniquePtrList<uint32_t>();
    auto v1 = new uint32_t(100);
    auto v2 = new uint32_t(5000);
    ls.Append(v1);
    ls.Append(v2);
    REQUIRE_THROWS(ls.At(-1));
    REQUIRE_THROWS(ls.At(2));
}

#endif