aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd
diff options
context:
space:
mode:
Diffstat (limited to 'libs/kstd')
-rw-r--r--libs/kstd/kstd/flat_map.tests.cpp43
1 files changed, 29 insertions, 14 deletions
diff --git a/libs/kstd/kstd/flat_map.tests.cpp b/libs/kstd/kstd/flat_map.tests.cpp
index 32dbafb2..5f29fa14 100644
--- a/libs/kstd/kstd/flat_map.tests.cpp
+++ b/libs/kstd/kstd/flat_map.tests.cpp
@@ -2,6 +2,7 @@
#include <kstd/allocator.hpp>
#include <kstd/test_support/os_panic.hpp>
+#include <kstd/test_support/test_types.hpp>
#include <kstd/vector.hpp>
#include <catch2/catch_test_macros.hpp>
@@ -104,10 +105,24 @@ SCENARIO("Flat Map initialization and construction", "[flat_map]")
REQUIRE(map.at(5) == 'f');
}
}
+ }
+
+ GIVEN("An unsorted key container and an unsorted value container using an allocator")
+ {
+ auto allocator = kstd::tests::tracking_allocator<int>{nullptr};
+
+ auto keys = kstd::vector{
+ {0, 5, 3, 4, 1, 2},
+ allocator
+ };
+ auto values = kstd::vector{
+ {0, 50, 30, 40, 10, 20},
+ allocator
+ };
WHEN("constructing using the containers and an allocator")
{
- auto map = kstd::flat_map{keys, values, kstd::allocator<int>{}};
+ auto map = kstd::flat_map{keys, values, allocator};
THEN("the flat map has size 6")
{
@@ -116,18 +131,18 @@ SCENARIO("Flat Map initialization and construction", "[flat_map]")
THEN("the flat map contains all pairs in order")
{
- REQUIRE(map.at(0) == 'a');
- REQUIRE(map.at(1) == 'b');
- REQUIRE(map.at(2) == 'c');
- REQUIRE(map.at(3) == 'd');
- REQUIRE(map.at(4) == 'e');
- REQUIRE(map.at(5) == 'f');
+ REQUIRE(map.at(0) == 0);
+ REQUIRE(map.at(1) == 10);
+ REQUIRE(map.at(2) == 20);
+ REQUIRE(map.at(3) == 30);
+ REQUIRE(map.at(4) == 40);
+ REQUIRE(map.at(5) == 50);
}
}
WHEN("constructing using the containers and an allocator and a comparator")
{
- auto map = kstd::flat_map{keys, values, std::less<>{}, kstd::allocator<int>{}};
+ auto map = kstd::flat_map{keys, values, std::less<>{}, allocator};
THEN("the flat map has size 6")
{
@@ -136,12 +151,12 @@ SCENARIO("Flat Map initialization and construction", "[flat_map]")
THEN("the flat map contains all pairs in order")
{
- REQUIRE(map.at(0) == 'a');
- REQUIRE(map.at(1) == 'b');
- REQUIRE(map.at(2) == 'c');
- REQUIRE(map.at(3) == 'd');
- REQUIRE(map.at(4) == 'e');
- REQUIRE(map.at(5) == 'f');
+ REQUIRE(map.at(0) == 0);
+ REQUIRE(map.at(1) == 10);
+ REQUIRE(map.at(2) == 20);
+ REQUIRE(map.at(3) == 30);
+ REQUIRE(map.at(4) == 40);
+ REQUIRE(map.at(5) == 50);
}
}
}