#include "kstd/tests/os_panic.hpp"
#include <kstd/ranges>
#include <kstd/tests/test_types.hpp>
#include <kstd/vector>
#include <catch2/catch_test_macros.hpp>
#include <array>
#include <iterator>
#include <ranges>
#include <utility>
SCENARIO("Vector initialization and construction", "[vector]")
{
GIVEN("An empty context")
{
WHEN("constructing by default")
{
auto v = kstd::vector<int>{};
THEN("the vector is empty")
{
REQUIRE(v.empty());
}
THEN("the size and capacity are zero")
{
REQUIRE(v.size() == 0);
REQUIRE(v.capacity() == 0);
}
}
WHEN("constructing with a specific size")
{
auto v = kstd::vector<int>(10);
THEN("the vector is not empty")
{
REQUIRE_FALSE(v.empty());
}
THEN("the size is and capacity match the specified value")
{
REQUIRE(v.size() == 10);
REQUIRE(v.capacity() == 10);
}
}
WHEN("constructing from an initializer list")
{
auto v = kstd::vector<int>{1, 2, 3, 4, 5};
THEN("the vector is not empty")
{
REQUIRE_FALSE(v.empty());
}
THEN("the size is and capacity match the specified value")
{
REQUIRE(v.size() == 5);
REQUIRE(v.capacity() == 5);
}
THEN("the elements are correctly initialized")
{
REQUIRE(v[0]