heterogeneous at, erase, count and equal_range

This commit is contained in:
2019-05-27 18:27:26 +07:00
parent 00d676f998
commit 6eaae5784f
8 changed files with 262 additions and 30 deletions

View File

@@ -412,13 +412,23 @@ TEST_CASE("flat_multimap") {
REQUIRE(my_as_const(s0).lower_bound(-1) == s0.cbegin());
REQUIRE(my_as_const(s0).lower_bound(7) == s0.cbegin() + 4);
}
{
flat_multimap<std::string, int, std::less<>> s0{{"hello", 42}, {"world", 84}};
REQUIRE(s0.find(std::string_view("hello")) == s0.begin());
REQUIRE(my_as_const(s0).find(std::string_view("world")) == s0.begin() + 1);
REQUIRE(s0.find(std::string_view("42")) == s0.end());
REQUIRE(my_as_const(s0).find(std::string_view("42")) == s0.cend());
}
}
SECTION("heterogeneous") {
flat_multimap<std::string, int, std::less<>> s0{{"hello", 42}, {"world", 84}};
REQUIRE(s0.find(std::string_view("hello")) == s0.begin());
REQUIRE(my_as_const(s0).find(std::string_view("world")) == s0.begin() + 1);
REQUIRE(s0.find(std::string_view("42")) == s0.end());
REQUIRE(my_as_const(s0).find(std::string_view("42")) == s0.cend());
REQUIRE(my_as_const(s0).count(std::string_view("hello")) == 1);
REQUIRE(my_as_const(s0).count(std::string_view("hello_42")) == 0);
REQUIRE(s0.upper_bound(std::string_view("hello")) == s0.begin() + 1);
REQUIRE(my_as_const(s0).upper_bound(std::string_view("hello")) == s0.begin() + 1);
REQUIRE(s0.erase(std::string_view("hello")) == 1);
REQUIRE(s0.at(std::string_view("world")) == 84);
REQUIRE(my_as_const(s0).at(std::string_view("world")) == 84);
}
SECTION("observers") {
struct my_less {