aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-05-01 17:27:00 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-05-01 17:27:00 +0200
commit3ba99c5c8643be35a2337c120b226b17ddfcf58f (patch)
tree9146b0ff77e05bfe46a2020adca063d5ce663e92 /libs
parent2773e457773e3c88c212d6403950cef1fc96f880 (diff)
downloadkernel-3ba99c5c8643be35a2337c120b226b17ddfcf58f.tar.xz
kernel-3ba99c5c8643be35a2337c120b226b17ddfcf58f.zip
kstd/vector: add missing emplace test
Diffstat (limited to 'libs')
-rw-r--r--libs/kstd/tests/src/vector.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/libs/kstd/tests/src/vector.cpp b/libs/kstd/tests/src/vector.cpp
index fd44437..4fb3559 100644
--- a/libs/kstd/tests/src/vector.cpp
+++ b/libs/kstd/tests/src/vector.cpp
@@ -761,6 +761,26 @@ SCENARIO("Vector modifiers", "[vector]")
}
}
+ WHEN("emplace is called with an iterator and sufficient capacity")
+ {
+ v.reserve(v.size() + 1);
+
+ auto it = v.emplace(v.begin() + 2, 25);
+
+ THEN("the element is inserted and the size and capacity increase")
+ {
+ REQUIRE(v.size() == 4);
+ REQUIRE(v.capacity() >= initial_capacity);
+ REQUIRE(v.at(2) == 25);
+ }
+
+ THEN("the returned iterator points to the inserted element")
+ {
+ REQUIRE(it == v.cbegin() + 2);
+ REQUIRE(*it == 25);
+ }
+ }
+
WHEN("push_back is called with a reference to an internal element")
{
v.shrink_to_fit();