aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd/tests/src
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-05-01 11:34:54 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-05-01 11:34:54 +0200
commita958c515e4cfcd5572ac7e2c3a567e832630a12d (patch)
treea5636689d2338c71e9b67d7ed1e2446b4d765a49 /libs/kstd/tests/src
parentbc7389dd19eee57fa2f34cf2e7ba7d1ebfad0878 (diff)
downloadkernel-a958c515e4cfcd5572ac7e2c3a567e832630a12d.tar.xz
kernel-a958c515e4cfcd5572ac7e2c3a567e832630a12d.zip
kstd/vector: implement append_range
Diffstat (limited to 'libs/kstd/tests/src')
-rw-r--r--libs/kstd/tests/src/vector.cpp31
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);
+ }
+ }
+
}
}