Introduce 'IntervalMapTest' fixture

This commit is contained in:
Bruno BELANYI 2024-08-23 23:15:12 +01:00
parent c8183d99a6
commit 6bc72fdc25

View file

@ -58,7 +58,20 @@ static_assert(std::is_same_v<
ValueInterface<int>, ValueInterface<int>,
decltype(std::numeric_limits<ValueInterface<int>>::lowest())>); decltype(std::numeric_limits<ValueInterface<int>>::lowest())>);
TEST(interval_map, minimal_interface) { class IntervalMapTest : public testing::Test {
protected:
using key_type = char;
using value_type = int;
using map_type = amby::interval_map<key_type, value_type>;
map_type map{0};
void SetUp() override {
map = map_type{0};
}
};
TEST_F(IntervalMapTest, minimal_interface) {
using Key = KeyInterface<char>; using Key = KeyInterface<char>;
using Value = ValueInterface<int>; using Value = ValueInterface<int>;
@ -67,16 +80,14 @@ TEST(interval_map, minimal_interface) {
map.assign(Key(0), Key(1), Value(1)); map.assign(Key(0), Key(1), Value(1));
} }
TEST(interval_map, no_insertion) { TEST_F(IntervalMapTest, no_insertion) {
auto map = amby::interval_map<char, int>{0};
for (int i = std::numeric_limits<char>::min(); for (int i = std::numeric_limits<char>::min();
i <= std::numeric_limits<char>::max(); ++i) { i <= std::numeric_limits<char>::max(); ++i) {
ASSERT_EQ(map[i], 0); ASSERT_EQ(map[i], 0);
} }
} }
TEST(interval_map, insert_begin_equal_end) { TEST_F(IntervalMapTest, insert_begin_equal_end) {
auto map = amby::interval_map<char, int>{0};
map.assign(0, 0, 1); map.assign(0, 0, 1);
for (int i = std::numeric_limits<char>::min(); for (int i = std::numeric_limits<char>::min();
i <= std::numeric_limits<char>::max(); ++i) { i <= std::numeric_limits<char>::max(); ++i) {
@ -84,8 +95,7 @@ TEST(interval_map, insert_begin_equal_end) {
} }
} }
TEST(interval_map, insert_begin_bigger_than_end) { TEST_F(IntervalMapTest, insert_begin_bigger_than_end) {
auto map = amby::interval_map<char, int>{0};
map.assign(1, 0, 1); map.assign(1, 0, 1);
for (int i = std::numeric_limits<char>::min(); for (int i = std::numeric_limits<char>::min();
i <= std::numeric_limits<char>::max(); ++i) { i <= std::numeric_limits<char>::max(); ++i) {