From 3ba99c5c8643be35a2337c120b226b17ddfcf58f Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 1 May 2026 17:27:00 +0200 Subject: kstd/vector: add missing emplace test --- libs/kstd/tests/src/vector.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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(); -- cgit v1.2.3