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

@@ -388,13 +388,21 @@ TEST_CASE("flat_multiset") {
REQUIRE(my_as_const(s0).lower_bound(-1) == s0.cbegin());
REQUIRE(my_as_const(s0).lower_bound(7) == s0.cbegin() + 4);
}
{
flat_multiset<std::string, std::less<>> s0{"hello", "world"};
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_multiset<std::string, std::less<>> s0{"hello", "world"};
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);
}
SECTION("observers") {
struct my_less {