From 6bc72fdc253419902af64a90898e876aac8776df Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 23 Aug 2024 23:15:12 +0100 Subject: [PATCH] Introduce 'IntervalMapTest' fixture --- tests/unit/unit_test.cc | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/unit/unit_test.cc b/tests/unit/unit_test.cc index b2b990e..3cdf79e 100644 --- a/tests/unit/unit_test.cc +++ b/tests/unit/unit_test.cc @@ -58,7 +58,20 @@ static_assert(std::is_same_v< ValueInterface, decltype(std::numeric_limits>::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; + + map_type map{0}; + + void SetUp() override { + map = map_type{0}; + } +}; + +TEST_F(IntervalMapTest, minimal_interface) { using Key = KeyInterface; using Value = ValueInterface; @@ -67,16 +80,14 @@ TEST(interval_map, minimal_interface) { map.assign(Key(0), Key(1), Value(1)); } -TEST(interval_map, no_insertion) { - auto map = amby::interval_map{0}; +TEST_F(IntervalMapTest, no_insertion) { for (int i = std::numeric_limits::min(); i <= std::numeric_limits::max(); ++i) { ASSERT_EQ(map[i], 0); } } -TEST(interval_map, insert_begin_equal_end) { - auto map = amby::interval_map{0}; +TEST_F(IntervalMapTest, insert_begin_equal_end) { map.assign(0, 0, 1); for (int i = std::numeric_limits::min(); i <= std::numeric_limits::max(); ++i) { @@ -84,8 +95,7 @@ TEST(interval_map, insert_begin_equal_end) { } } -TEST(interval_map, insert_begin_bigger_than_end) { - auto map = amby::interval_map{0}; +TEST_F(IntervalMapTest, insert_begin_bigger_than_end) { map.assign(1, 0, 1); for (int i = std::numeric_limits::min(); i <= std::numeric_limits::max(); ++i) {