Handle empty range insertion

This commit is contained in:
Bruno BELANYI 2024-08-23 22:13:34 +01:00
parent 5292c22e2c
commit c8183d99a6
2 changed files with 28 additions and 0 deletions

View file

@ -9,6 +9,8 @@ public:
interval_map(V const& init) : init_(init) {}
void assign(K const& begin, K const& end, V const& val) {
if (!(begin < end))
return;
// TODO: implement
}

View file

@ -66,3 +66,29 @@ TEST(interval_map, minimal_interface) {
ASSERT_EQ(map[Key(0)], Value(0));
map.assign(Key(0), Key(1), Value(1));
}
TEST(interval_map, no_insertion) {
auto map = amby::interval_map<char, int>{0};
for (int i = std::numeric_limits<char>::min();
i <= std::numeric_limits<char>::max(); ++i) {
ASSERT_EQ(map[i], 0);
}
}
TEST(interval_map, insert_begin_equal_end) {
auto map = amby::interval_map<char, int>{0};
map.assign(0, 0, 1);
for (int i = std::numeric_limits<char>::min();
i <= std::numeric_limits<char>::max(); ++i) {
ASSERT_EQ(map[i], 0);
}
}
TEST(interval_map, insert_begin_bigger_than_end) {
auto map = amby::interval_map<char, int>{0};
map.assign(1, 0, 1);
for (int i = std::numeric_limits<char>::min();
i <= std::numeric_limits<char>::max(); ++i) {
ASSERT_EQ(map[i], 0);
}
}