diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-03-30 12:41:14 +0000 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-03-30 12:41:14 +0000 |
| commit | c946cf6a89bbeae7fb96a67b55d91b7ae0cfa48d (patch) | |
| tree | 1a34c64b82b559ee3f76352a3194faf1c24a733e /libs/kstd/tests/src | |
| parent | 706f529722520429860ce60237d4ef71b2b27601 (diff) | |
| download | teachos-c946cf6a89bbeae7fb96a67b55d91b7ae0cfa48d.tar.xz teachos-c946cf6a89bbeae7fb96a67b55d91b7ae0cfa48d.zip | |
kstd/flat_map: fix iterator reference
Diffstat (limited to 'libs/kstd/tests/src')
| -rw-r--r-- | libs/kstd/tests/src/flat_map.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libs/kstd/tests/src/flat_map.cpp b/libs/kstd/tests/src/flat_map.cpp index cde136a..eb599af 100644 --- a/libs/kstd/tests/src/flat_map.cpp +++ b/libs/kstd/tests/src/flat_map.cpp @@ -4,6 +4,8 @@ #include <catch2/catch_test_macros.hpp> #include <functional> +#include <type_traits> +#include <utility> SCENARIO("Flat Map initialization and construction", "[flat_map]") { @@ -159,6 +161,29 @@ SCENARIO("Flat Map iterators", "[flat_map]") ++it; REQUIRE(it == map.cend()); } + + THEN("assignment through the proxy modifies the mapped value") + { + auto it = map.begin(); + + *it = std::pair{1, 100}; + + REQUIRE(it->second == 100); + REQUIRE(map.at(1) == 100); + } + + THEN("structured bindings evaluate correctly") + { + auto it = map.cbegin(); + + auto [key, value] = *it; + + REQUIRE(key == 1); + REQUIRE(value == 10); + + STATIC_REQUIRE(std::is_same_v<decltype(key), int const &>); + STATIC_REQUIRE(std::is_same_v<decltype(value), int const &>); + } } WHEN("using reverse iterators") |
