diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-05-01 11:34:54 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-05-01 11:34:54 +0200 |
| commit | a958c515e4cfcd5572ac7e2c3a567e832630a12d (patch) | |
| tree | a5636689d2338c71e9b67d7ed1e2446b4d765a49 /libs/kstd/tests | |
| parent | bc7389dd19eee57fa2f34cf2e7ba7d1ebfad0878 (diff) | |
| download | kernel-a958c515e4cfcd5572ac7e2c3a567e832630a12d.tar.xz kernel-a958c515e4cfcd5572ac7e2c3a567e832630a12d.zip | |
kstd/vector: implement append_range
Diffstat (limited to 'libs/kstd/tests')
| -rw-r--r-- | libs/kstd/tests/src/vector.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libs/kstd/tests/src/vector.cpp b/libs/kstd/tests/src/vector.cpp index b838f42..bbbd3d1 100644 --- a/libs/kstd/tests/src/vector.cpp +++ b/libs/kstd/tests/src/vector.cpp @@ -516,6 +516,21 @@ SCENARIO("Vector modifiers", "[vector]") REQUIRE(it == v.begin()); } } + + WHEN("appending a range") + { + auto const range = std::views::iota(0, 3); + v.append_range(range); + + THEN("the size and capacity increase and the elements are appended") + { + REQUIRE(v.size() == 3); + REQUIRE(v.capacity() >= 3); + REQUIRE(v[0] == 0); + REQUIRE(v[1] == 1); + REQUIRE(v[2] == 2); + } + } } GIVEN("A populated vector") @@ -832,6 +847,22 @@ SCENARIO("Vector modifiers", "[vector]") REQUIRE(it == v.begin() + 1); } } + + WHEN("appending a range") + { + auto initial_size = v.size(); + v.append_range(std::views::iota(0, 3)); + + THEN("capacity and size are increased and the elements are appended") + { + REQUIRE(v.capacity() >= initial_capacity); + REQUIRE(v.size() == initial_size + 3); + REQUIRE(v[initial_size + 0] == 0); + REQUIRE(v[initial_size + 1] == 1); + REQUIRE(v[initial_size + 2] == 2); + } + } + } } |
