diff --git a/.gitignore b/.gitignore index 79641999..a1decab8 100644 --- a/.gitignore +++ b/.gitignore @@ -402,3 +402,4 @@ test/etl_error_handler/assert_function/build-make test/syntax_check/bgcc test/vs2022/Debug MSVC C++23 test/vs2022/Debug MSVC C++23 - No STL +.vs diff --git a/include/etl/const_map.h b/include/etl/const_map.h index 01a2830d..af9905f7 100644 --- a/include/etl/const_map.h +++ b/include/etl/const_map.h @@ -41,6 +41,7 @@ SOFTWARE. #include "type_traits.h" #include "functional.h" #include "nth_type.h" +#include "span.h" #include "private/comparator_is_transparent.h" @@ -391,7 +392,7 @@ namespace etl //************************************************************************* ETL_CONSTEXPR14 size_type full() const ETL_NOEXCEPT { - return size() == max_elements; + return (max_elements != 0) && (size() == max_elements); } //************************************************************************* @@ -446,7 +447,7 @@ namespace etl /// Constructor //************************************************************************* template - ETL_CONSTEXPR14 explicit iconst_map(value_type* element_list_, size_type size_, size_type max_elements_) ETL_NOEXCEPT + ETL_CONSTEXPR14 explicit iconst_map(const value_type* element_list_, size_type size_, size_type max_elements_) ETL_NOEXCEPT : element_list(element_list_) , element_list_end{element_list_ + size_} , max_elements(max_elements_) @@ -475,9 +476,9 @@ namespace etl value_compare vcompare; - value_type* element_list; - value_type* element_list_end; - size_type max_elements; + const value_type* element_list; + const value_type* element_list_end; + size_type max_elements; }; //********************************************************************* @@ -490,22 +491,24 @@ namespace etl using base_t = iconst_map; - using key_type = typename base_t::key_type; - using value_type = typename base_t::value_type; - using mapped_type = typename base_t::mapped_type ; - using key_compare = typename base_t::key_compare; - using const_reference = typename base_t::const_reference; - using const_pointer = typename base_t::const_pointer; - using const_iterator = typename base_t::const_iterator; - using size_type = typename base_t::size_type; + using key_type = typename base_t::key_type; + using value_type = typename base_t::value_type; + using mapped_type = typename base_t::mapped_type ; + using key_compare = typename base_t::key_compare; + using const_reference = typename base_t::const_reference; + using const_pointer = typename base_t::const_pointer; + using const_iterator = typename base_t::const_iterator; + using size_type = typename base_t::size_type; /// Defines the parameter types using const_key_reference = const key_type&; using const_mapped_reference = const mapped_type&; + static_assert((etl::is_default_constructible::value), "key_type must be default constructible"); + static_assert((etl::is_default_constructible::value), "mapped_type must be default constructible"); + //************************************************************************* ///\brief Construct a const_map from a variadic list of elements. - /// Static asserts if the element type is not constructible. /// Static asserts if the elements are not of type value_type. /// Static asserts if the number of elements is greater than the capacity of the const_map. //************************************************************************* @@ -514,8 +517,6 @@ namespace etl : iconst_map(element_list, sizeof...(elements), Size) , element_list{etl::forward(elements)...} { - static_assert((etl::is_default_constructible::value), "key_type must be default constructible"); - static_assert((etl::is_default_constructible::value), "mapped_type must be default constructible"); static_assert((etl::are_all_same...>::value), "All elements must be value_type"); static_assert(sizeof...(elements) <= Size, "Number of elements exceeds capacity"); } @@ -529,10 +530,74 @@ namespace etl /// Template deduction guides. //************************************************************************* #if ETL_USING_CPP17 - template - const_map(TPairs...) -> const_map::first_type, - typename etl::nth_type_t<0, TPairs...>::second_type, - sizeof...(TPairs)>; + template + const_map(TElements...) -> const_map::first_type, + typename etl::nth_type_t<0, TElements...>::second_type, + sizeof...(TElements)>; +#endif + + //********************************************************************* + /// Map type designed for constexpr. + //********************************************************************* + template > + class const_map_ext : public iconst_map + { + public: + + using base_t = iconst_map; + + using key_type = typename base_t::key_type; + using value_type = typename base_t::value_type; + using mapped_type = typename base_t::mapped_type ; + using key_compare = typename base_t::key_compare; + using const_reference = typename base_t::const_reference; + using const_pointer = typename base_t::const_pointer; + using const_iterator = typename base_t::const_iterator; + using size_type = typename base_t::size_type; + + /// Defines the parameter types + using const_key_reference = const key_type&; + using const_mapped_reference = const mapped_type&; + + static_assert((etl::is_default_constructible::value), "key_type must be default constructible"); + static_assert((etl::is_default_constructible::value), "mapped_type must be default constructible"); + + //************************************************************************* + ///\brief Default construct a const_map. + //************************************************************************* + ETL_CONSTEXPR14 const_map_ext() ETL_NOEXCEPT + : iconst_map(nullptr, 0, 0) + { + } + + //************************************************************************* + ///\brief Construct a const_map from a variadic list of elements. + //************************************************************************* + template + ETL_CONSTEXPR14 explicit const_map_ext(const etl::span& sp) ETL_NOEXCEPT + : iconst_map(sp.data(), Size, Size) + { + } + + //************************************************************************* + ///\brief Construct a const_map from an array. + //************************************************************************* + template + ETL_CONSTEXPR14 explicit const_map_ext(const value_type(&begin_)[Size]) ETL_NOEXCEPT + : iconst_map(begin_, Size, Size) + { + } + }; + + //************************************************************************* + /// Template deduction guides. + //************************************************************************* +#if ETL_USING_CPP17 + template + const_map_ext(const etl::span&) -> const_map_ext; + + template + const_map_ext(const TElements(&)[N]) -> const_map_ext; #endif //************************************************************************* @@ -540,7 +605,7 @@ namespace etl //************************************************************************* template ETL_CONSTEXPR14 bool operator ==(const etl::iconst_map& lhs, - const etl::iconst_map& rhs) + const etl::iconst_map& rhs) ETL_NOEXCEPT { return etl::equal(lhs.begin(), lhs.end(), rhs.begin()); } @@ -550,7 +615,7 @@ namespace etl //************************************************************************* template ETL_CONSTEXPR14 bool operator !=(const etl::iconst_map& lhs, - const etl::iconst_map& rhs) + const etl::iconst_map& rhs) ETL_NOEXCEPT { return !(lhs == rhs); } @@ -560,7 +625,7 @@ namespace etl //************************************************************************* template ETL_CONSTEXPR14 bool operator <(const etl::iconst_map& lhs, - const etl::iconst_map& rhs) + const etl::iconst_map& rhs) ETL_NOEXCEPT { return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), @@ -572,7 +637,7 @@ namespace etl //************************************************************************* template ETL_CONSTEXPR14 bool operator >(const etl::iconst_map& lhs, - const etl::iconst_map& rhs) + const etl::iconst_map& rhs) ETL_NOEXCEPT { return (rhs < lhs); } @@ -582,7 +647,7 @@ namespace etl //************************************************************************* template ETL_CONSTEXPR14 bool operator <=(const etl::iconst_map& lhs, - const etl::iconst_map& rhs) + const etl::iconst_map& rhs) ETL_NOEXCEPT { return !(rhs < lhs); } @@ -592,7 +657,7 @@ namespace etl //************************************************************************* template ETL_CONSTEXPR14 bool operator >=(const etl::iconst_map& lhs, - const etl::iconst_map& rhs) + const etl::iconst_map& rhs) ETL_NOEXCEPT { return !(lhs < rhs); } diff --git a/include/etl/const_multimap.h b/include/etl/const_multimap.h index dd27984b..7b7c3968 100644 --- a/include/etl/const_multimap.h +++ b/include/etl/const_multimap.h @@ -31,7 +31,7 @@ SOFTWARE. #ifndef ETL_CONST_MULTIMAP_INCLUDED #define ETL_CONST_MULTIMAP_INCLUDED -#include "platform.h" +#include "platform.h" #if ETL_NOT_USING_CPP11 #error NOT SUPPORTED FOR C++03 OR BELOW @@ -41,6 +41,7 @@ SOFTWARE. #include "type_traits.h" #include "functional.h" #include "nth_type.h" +#include "span.h" #include "private/comparator_is_transparent.h" @@ -54,14 +55,14 @@ namespace etl { public: - using key_type = TKey; - using value_type = ETL_OR_STD::pair; - using mapped_type = TMapped ; - using key_compare = TKeyCompare; - using const_reference = const value_type&; - using const_pointer = const value_type*; - using const_iterator = const value_type*; - using size_type = size_t; + using key_type = TKey; + using value_type = ETL_OR_STD::pair; + using mapped_type = TMapped ; + using key_compare = TKeyCompare; + using const_reference = const value_type&; + using const_pointer = const value_type*; + using const_iterator = const value_type*; + using size_type = size_t; /// Defines the parameter types using const_key_reference = const key_type&; @@ -343,7 +344,7 @@ namespace etl //************************************************************************* ETL_CONSTEXPR14 size_type full() const ETL_NOEXCEPT { - return size() == max_elements; + return (max_elements != 0) && (size() == max_elements); } //************************************************************************* @@ -398,7 +399,7 @@ namespace etl /// Constructor //************************************************************************* template - ETL_CONSTEXPR14 explicit iconst_multimap(value_type* element_list_, size_type size_, size_type max_elements_) ETL_NOEXCEPT + ETL_CONSTEXPR14 explicit iconst_multimap(const value_type* element_list_, size_type size_, size_type max_elements_) ETL_NOEXCEPT : element_list(element_list_) , element_list_end{element_list_ + size_} , max_elements(max_elements_) @@ -427,8 +428,8 @@ namespace etl value_compare vcompare; - value_type* element_list; - value_type* element_list_end; + const value_type* element_list; + const value_type* element_list_end; size_type max_elements; }; @@ -455,6 +456,9 @@ namespace etl using const_key_reference = const key_type&; using const_mapped_reference = const mapped_type&; + static_assert((etl::is_default_constructible::value), "key_type must be default constructible"); + static_assert((etl::is_default_constructible::value), "mapped_type must be default constructible"); + //************************************************************************* ///\brief Construct a const_map from a variadic list of elements. /// Static asserts if the element type is not constructible. @@ -466,8 +470,6 @@ namespace etl : iconst_multimap(element_list, sizeof...(elements), Size) , element_list{etl::forward(elements)...} { - static_assert((etl::is_default_constructible::value), "key_type must be default constructible"); - static_assert((etl::is_default_constructible::value), "mapped_type must be default constructible"); static_assert((etl::are_all_same...>::value), "All elements must be value_type"); static_assert(sizeof...(elements) <= Size, "Number of elements exceeds capacity"); } @@ -483,8 +485,72 @@ namespace etl #if ETL_USING_CPP17 template const_multimap(TPairs...) -> const_multimap::first_type, - typename etl::nth_type_t<0, TPairs...>::second_type, - sizeof...(TPairs)>; + typename etl::nth_type_t<0, TPairs...>::second_type, + sizeof...(TPairs)>; +#endif + + //********************************************************************* + /// Map type designed for constexpr. + //********************************************************************* + template > + class const_multimap_ext : public iconst_multimap + { + public: + + using base_t = iconst_multimap; + + using key_type = typename base_t::key_type; + using value_type = typename base_t::value_type; + using mapped_type = typename base_t::mapped_type ; + using key_compare = typename base_t::key_compare; + using const_reference = typename base_t::const_reference; + using const_pointer = typename base_t::const_pointer; + using const_iterator = typename base_t::const_iterator; + using size_type = typename base_t::size_type; + + /// Defines the parameter types + using const_key_reference = const key_type&; + using const_mapped_reference = const mapped_type&; + + static_assert((etl::is_default_constructible::value), "key_type must be default constructible"); + static_assert((etl::is_default_constructible::value), "mapped_type must be default constructible"); + + //************************************************************************* + ///\brief Default construct a const_map. + //************************************************************************* + ETL_CONSTEXPR14 const_multimap_ext() ETL_NOEXCEPT + : iconst_multimap(nullptr, 0, 0) + { + } + + //************************************************************************* + ///\brief Construct a const_map from a variadic list of elements. + //************************************************************************* + template + ETL_CONSTEXPR14 explicit const_multimap_ext(const etl::span& sp) ETL_NOEXCEPT + : iconst_multimap(sp.data(), Size, Size) + { + } + + //************************************************************************* + ///\brief Construct a const_map from an array. + //************************************************************************* + template + ETL_CONSTEXPR14 explicit const_multimap_ext(const value_type(&begin_)[Size]) ETL_NOEXCEPT + : iconst_multimap(begin_, Size, Size) + { + } + }; + + //************************************************************************* + /// Template deduction guides. + //************************************************************************* +#if ETL_USING_CPP17 + template + const_multimap_ext(const etl::span&) -> const_multimap_ext; + + template + const_multimap_ext(const TElements(&)[N]) -> const_multimap_ext; #endif //************************************************************************* @@ -492,7 +558,7 @@ namespace etl //************************************************************************* template ETL_CONSTEXPR14 bool operator ==(const etl::iconst_multimap& lhs, - const etl::iconst_multimap& rhs) + const etl::iconst_multimap& rhs) ETL_NOEXCEPT { return etl::equal(lhs.begin(), lhs.end(), rhs.begin()); } @@ -502,7 +568,7 @@ namespace etl //************************************************************************* template ETL_CONSTEXPR14 bool operator !=(const etl::iconst_multimap& lhs, - const etl::iconst_multimap& rhs) + const etl::iconst_multimap& rhs) ETL_NOEXCEPT { return !(lhs == rhs); } diff --git a/test/test_const_map.cpp b/test/test_const_map.cpp index 40624772..19fb9980 100644 --- a/test/test_const_map.cpp +++ b/test/test_const_map.cpp @@ -103,8 +103,10 @@ namespace using IDataTransparentComparator = etl::iconst_map>; #endif - using value_type = Data::value_type; - using Data_const_iterator = Data::const_iterator; + using value_type = Data::value_type; + using key_type = Data::key_type; + using mapped_type = Data::mapped_type; + using const_iterator = Data::const_iterator; SUITE(test_const_map) { @@ -113,14 +115,14 @@ namespace { static const Data data; - static const bool is_valid = data.is_valid(); - static const size_t size = data.size(); - static const bool empty = data.empty(); - static const bool full = data.full(); - static const size_t capacity = data.capacity(); - static const size_t max_size = data.max_size(); - static const Data::const_iterator begin = data.begin(); - static const Data::const_iterator end = data.end(); + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == 0UL); @@ -136,14 +138,14 @@ namespace { static const Data data{ value_type{Key('A'), 0 } }; - static const bool is_valid = data.is_valid(); - static const size_t size = data.size(); - static const bool empty = data.empty(); - static const bool full = data.full(); - static const size_t capacity = data.capacity(); - static const size_t max_size = data.max_size(); - static const Data::const_iterator begin = data.begin(); - static const Data::const_iterator end = data.end(); + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == 1U); @@ -165,14 +167,14 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static const bool is_valid = data.is_valid(); - static const size_t size = data.size(); - static const bool empty = data.empty(); - static const bool full = data.full(); - static const size_t capacity = data.capacity(); - static const size_t max_size = data.max_size(); - static const Data::const_iterator begin = data.begin(); - static const Data::const_iterator end = data.end(); + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == Max_Size); @@ -196,14 +198,14 @@ namespace static const IData& idata = data; - static const bool is_valid = idata.is_valid(); - static const size_t size = idata.size(); - static const bool empty = idata.empty(); - static const bool full = idata.full(); - static const size_t capacity = idata.capacity(); - static const size_t max_size = idata.max_size(); - static const Data::const_iterator begin = idata.begin(); - static const Data::const_iterator end = idata.end(); + static const bool is_valid = idata.is_valid(); + static const size_t size = idata.size(); + static const bool empty = idata.empty(); + static const bool full = idata.full(); + static const size_t capacity = idata.capacity(); + static const size_t max_size = idata.max_size(); + static const const_iterator begin = idata.begin(); + static const const_iterator end = idata.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == Max_Size); @@ -228,21 +230,11 @@ namespace //************************************************************************* TEST(test_cpp17_deduced_constructor) { -#ifdef TEST_GREATER_THAN - static const Data data{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; -#else - static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; -#endif - -#ifdef TEST_GREATER_THAN - etl::const_map check{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; -#else + static const etl::const_map data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; etl::const_map check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; -#endif + CHECK_TRUE(data.is_valid()); CHECK_TRUE(data.size() == Max_Size); CHECK_FALSE(data.empty()); @@ -278,9 +270,9 @@ namespace TEST(test_end_const) { static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; - static const Data::const_iterator end_itr = data.end(); + static const const_iterator end_itr = data.end(); CHECK_TRUE(end_itr == (data.begin() + data.size())); } @@ -296,16 +288,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static const Data::mapped_type atA = data[Key('A')]; - static const Data::mapped_type atB = data[Key('B')]; - static const Data::mapped_type atC = data[Key('C')]; - static const Data::mapped_type atD = data[Key('D')]; - static const Data::mapped_type atE = data[Key('E')]; - static const Data::mapped_type atF = data[Key('F')]; - static const Data::mapped_type atG = data[Key('G')]; - static const Data::mapped_type atH = data[Key('H')]; - static const Data::mapped_type atI = data[Key('I')]; - static const Data::mapped_type atJ = data[Key('J')]; + static const mapped_type atA = data[Key('A')]; + static const mapped_type atB = data[Key('B')]; + static const mapped_type atC = data[Key('C')]; + static const mapped_type atD = data[Key('D')]; + static const mapped_type atE = data[Key('E')]; + static const mapped_type atF = data[Key('F')]; + static const mapped_type atG = data[Key('G')]; + static const mapped_type atH = data[Key('H')]; + static const mapped_type atI = data[Key('I')]; + static const mapped_type atJ = data[Key('J')]; CHECK_TRUE(data.is_valid()); CHECK(atA == 0); @@ -331,16 +323,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static const Data::mapped_type atA = data['A']; - static const Data::mapped_type atB = data['B']; - static const Data::mapped_type atC = data['C']; - static const Data::mapped_type atD = data['D']; - static const Data::mapped_type atE = data['E']; - static const Data::mapped_type atF = data['F']; - static const Data::mapped_type atG = data['G']; - static const Data::mapped_type atH = data['H']; - static const Data::mapped_type atI = data['I']; - static const Data::mapped_type atJ = data['J']; + static const mapped_type atA = data['A']; + static const mapped_type atB = data['B']; + static const mapped_type atC = data['C']; + static const mapped_type atD = data['D']; + static const mapped_type atE = data['E']; + static const mapped_type atF = data['F']; + static const mapped_type atG = data['G']; + static const mapped_type atH = data['H']; + static const mapped_type atI = data['I']; + static const mapped_type atJ = data['J']; CHECK_TRUE(data.is_valid()); CHECK(atA == 0); @@ -366,16 +358,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static const Data::mapped_type atA = data.at(Key('A')); - static const Data::mapped_type atB = data.at(Key('B')); - static const Data::mapped_type atC = data.at(Key('C')); - static const Data::mapped_type atD = data.at(Key('D')); - static const Data::mapped_type atE = data.at(Key('E')); - static const Data::mapped_type atF = data.at(Key('F')); - static const Data::mapped_type atG = data.at(Key('G')); - static const Data::mapped_type atH = data.at(Key('H')); - static const Data::mapped_type atI = data.at(Key('I')); - static const Data::mapped_type atJ = data.at(Key('J')); + static const mapped_type atA = data.at(Key('A')); + static const mapped_type atB = data.at(Key('B')); + static const mapped_type atC = data.at(Key('C')); + static const mapped_type atD = data.at(Key('D')); + static const mapped_type atE = data.at(Key('E')); + static const mapped_type atF = data.at(Key('F')); + static const mapped_type atG = data.at(Key('G')); + static const mapped_type atH = data.at(Key('H')); + static const mapped_type atI = data.at(Key('I')); + static const mapped_type atJ = data.at(Key('J')); CHECK_TRUE(data.is_valid()); CHECK(atA == 0); @@ -401,16 +393,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static const Data::mapped_type atA = data.at('A'); - static const Data::mapped_type atB = data.at('B'); - static const Data::mapped_type atC = data.at('C'); - static const Data::mapped_type atD = data.at('D'); - static const Data::mapped_type atE = data.at('E'); - static const Data::mapped_type atF = data.at('F'); - static const Data::mapped_type atG = data.at('G'); - static const Data::mapped_type atH = data.at('H'); - static const Data::mapped_type atI = data.at('I'); - static const Data::mapped_type atJ = data.at('J'); + static const mapped_type atA = data.at('A'); + static const mapped_type atB = data.at('B'); + static const mapped_type atC = data.at('C'); + static const mapped_type atD = data.at('D'); + static const mapped_type atE = data.at('E'); + static const mapped_type atF = data.at('F'); + static const mapped_type atG = data.at('G'); + static const mapped_type atH = data.at('H'); + static const mapped_type atI = data.at('I'); + static const mapped_type atJ = data.at('J'); CHECK_TRUE(data.is_valid()); CHECK(atA == 0); @@ -436,16 +428,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static const ETL_OR_STD::pair resultA = data.equal_range(Key('A')); - static const ETL_OR_STD::pair resultB = data.equal_range(Key('B')); - static const ETL_OR_STD::pair resultC = data.equal_range(Key('C')); - static const ETL_OR_STD::pair resultD = data.equal_range(Key('D')); - static const ETL_OR_STD::pair resultE = data.equal_range(Key('E')); - static const ETL_OR_STD::pair resultF = data.equal_range(Key('F')); - static const ETL_OR_STD::pair resultG = data.equal_range(Key('G')); - static const ETL_OR_STD::pair resultH = data.equal_range(Key('H')); - static const ETL_OR_STD::pair resultI = data.equal_range(Key('I')); - static const ETL_OR_STD::pair resultJ = data.equal_range(Key('J')); + static const ETL_OR_STD::pair resultA = data.equal_range(Key('A')); + static const ETL_OR_STD::pair resultB = data.equal_range(Key('B')); + static const ETL_OR_STD::pair resultC = data.equal_range(Key('C')); + static const ETL_OR_STD::pair resultD = data.equal_range(Key('D')); + static const ETL_OR_STD::pair resultE = data.equal_range(Key('E')); + static const ETL_OR_STD::pair resultF = data.equal_range(Key('F')); + static const ETL_OR_STD::pair resultG = data.equal_range(Key('G')); + static const ETL_OR_STD::pair resultH = data.equal_range(Key('H')); + static const ETL_OR_STD::pair resultI = data.equal_range(Key('I')); + static const ETL_OR_STD::pair resultJ = data.equal_range(Key('J')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); @@ -499,22 +491,22 @@ namespace { #ifdef TEST_GREATER_THAN static const DataTransparentComparator data{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const DataTransparentComparator data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static const ETL_OR_STD::pair resultA = data.equal_range('A'); - static const ETL_OR_STD::pair resultB = data.equal_range('B'); - static const ETL_OR_STD::pair resultC = data.equal_range('C'); - static const ETL_OR_STD::pair resultD = data.equal_range('D'); - static const ETL_OR_STD::pair resultE = data.equal_range('E'); - static const ETL_OR_STD::pair resultF = data.equal_range('F'); - static const ETL_OR_STD::pair resultG = data.equal_range('G'); - static const ETL_OR_STD::pair resultH = data.equal_range('H'); - static const ETL_OR_STD::pair resultI = data.equal_range('I'); - static const ETL_OR_STD::pair resultJ = data.equal_range('J'); + static const ETL_OR_STD::pair resultA = data.equal_range('A'); + static const ETL_OR_STD::pair resultB = data.equal_range('B'); + static const ETL_OR_STD::pair resultC = data.equal_range('C'); + static const ETL_OR_STD::pair resultD = data.equal_range('D'); + static const ETL_OR_STD::pair resultE = data.equal_range('E'); + static const ETL_OR_STD::pair resultF = data.equal_range('F'); + static const ETL_OR_STD::pair resultG = data.equal_range('G'); + static const ETL_OR_STD::pair resultH = data.equal_range('H'); + static const ETL_OR_STD::pair resultI = data.equal_range('I'); + static const ETL_OR_STD::pair resultJ = data.equal_range('J'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); @@ -568,23 +560,23 @@ namespace { #ifdef TEST_GREATER_THAN static const Data data{ value_type{Key('K'), 10 }, value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, - value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, - value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; + value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; #endif - static const Data::const_iterator resultA = data.lower_bound(Key('A')); - static const Data::const_iterator resultB = data.lower_bound(Key('B')); - static const Data::const_iterator resultC = data.lower_bound(Key('C')); - static const Data::const_iterator resultD = data.lower_bound(Key('D')); - static const Data::const_iterator resultE = data.lower_bound(Key('E')); - static const Data::const_iterator resultF = data.lower_bound(Key('F')); - static const Data::const_iterator resultG = data.lower_bound(Key('G')); - static const Data::const_iterator resultH = data.lower_bound(Key('H')); - static const Data::const_iterator resultI = data.lower_bound(Key('I')); - static const Data::const_iterator resultJ = data.lower_bound(Key('J')); - static const Data::const_iterator resultK = data.lower_bound(Key('K')); + static const const_iterator resultA = data.lower_bound(Key('A')); + static const const_iterator resultB = data.lower_bound(Key('B')); + static const const_iterator resultC = data.lower_bound(Key('C')); + static const const_iterator resultD = data.lower_bound(Key('D')); + static const const_iterator resultE = data.lower_bound(Key('E')); + static const const_iterator resultF = data.lower_bound(Key('F')); + static const const_iterator resultG = data.lower_bound(Key('G')); + static const const_iterator resultH = data.lower_bound(Key('H')); + static const const_iterator resultI = data.lower_bound(Key('I')); + static const const_iterator resultJ = data.lower_bound(Key('J')); + static const const_iterator resultK = data.lower_bound(Key('K')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -618,23 +610,23 @@ namespace { #ifdef TEST_GREATER_THAN static const DataTransparentComparator data{ value_type{Key('K'), 10 }, value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, - value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const DataTransparentComparator data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, - value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; + value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; #endif - static const Data::const_iterator resultA = data.lower_bound('A'); - static const Data::const_iterator resultB = data.lower_bound('B'); - static const Data::const_iterator resultC = data.lower_bound('C'); - static const Data::const_iterator resultD = data.lower_bound('D'); - static const Data::const_iterator resultE = data.lower_bound('E'); - static const Data::const_iterator resultF = data.lower_bound('F'); - static const Data::const_iterator resultG = data.lower_bound('G'); - static const Data::const_iterator resultH = data.lower_bound('H'); - static const Data::const_iterator resultI = data.lower_bound('I'); - static const Data::const_iterator resultJ = data.lower_bound('J'); - static const Data::const_iterator resultK = data.lower_bound('K'); + static const const_iterator resultA = data.lower_bound('A'); + static const const_iterator resultB = data.lower_bound('B'); + static const const_iterator resultC = data.lower_bound('C'); + static const const_iterator resultD = data.lower_bound('D'); + static const const_iterator resultE = data.lower_bound('E'); + static const const_iterator resultF = data.lower_bound('F'); + static const const_iterator resultG = data.lower_bound('G'); + static const const_iterator resultH = data.lower_bound('H'); + static const const_iterator resultI = data.lower_bound('I'); + static const const_iterator resultJ = data.lower_bound('J'); + static const const_iterator resultK = data.lower_bound('K'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -668,23 +660,23 @@ namespace { #ifdef TEST_GREATER_THAN static const Data data{ value_type{Key('K'), 10 }, value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, - value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, - value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; + value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; #endif - static const Data::const_iterator resultA = data.upper_bound(Key('A')); - static const Data::const_iterator resultB = data.upper_bound(Key('B')); - static const Data::const_iterator resultC = data.upper_bound(Key('C')); - static const Data::const_iterator resultD = data.upper_bound(Key('D')); - static const Data::const_iterator resultE = data.upper_bound(Key('E')); - static const Data::const_iterator resultF = data.upper_bound(Key('F')); - static const Data::const_iterator resultG = data.upper_bound(Key('G')); - static const Data::const_iterator resultH = data.upper_bound(Key('H')); - static const Data::const_iterator resultI = data.upper_bound(Key('I')); - static const Data::const_iterator resultJ = data.upper_bound(Key('J')); - static const Data::const_iterator resultK = data.upper_bound(Key('K')); + static const const_iterator resultA = data.upper_bound(Key('A')); + static const const_iterator resultB = data.upper_bound(Key('B')); + static const const_iterator resultC = data.upper_bound(Key('C')); + static const const_iterator resultD = data.upper_bound(Key('D')); + static const const_iterator resultE = data.upper_bound(Key('E')); + static const const_iterator resultF = data.upper_bound(Key('F')); + static const const_iterator resultG = data.upper_bound(Key('G')); + static const const_iterator resultH = data.upper_bound(Key('H')); + static const const_iterator resultI = data.upper_bound(Key('I')); + static const const_iterator resultJ = data.upper_bound(Key('J')); + static const const_iterator resultK = data.upper_bound(Key('K')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); @@ -718,23 +710,23 @@ namespace { #ifdef TEST_GREATER_THAN static const DataTransparentComparator data{ value_type{Key('K'), 10 }, value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, - value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const DataTransparentComparator data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, - value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; + value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; #endif - static const Data::const_iterator resultA = data.upper_bound('A'); - static const Data::const_iterator resultB = data.upper_bound('B'); - static const Data::const_iterator resultC = data.upper_bound('C'); - static const Data::const_iterator resultD = data.upper_bound('D'); - static const Data::const_iterator resultE = data.upper_bound('E'); - static const Data::const_iterator resultF = data.upper_bound('F'); - static const Data::const_iterator resultG = data.upper_bound('G'); - static const Data::const_iterator resultH = data.upper_bound('H'); - static const Data::const_iterator resultI = data.upper_bound('I'); - static const Data::const_iterator resultJ = data.upper_bound('J'); - static const Data::const_iterator resultK = data.upper_bound('K'); + static const const_iterator resultA = data.upper_bound('A'); + static const const_iterator resultB = data.upper_bound('B'); + static const const_iterator resultC = data.upper_bound('C'); + static const const_iterator resultD = data.upper_bound('D'); + static const const_iterator resultE = data.upper_bound('E'); + static const const_iterator resultF = data.upper_bound('F'); + static const const_iterator resultG = data.upper_bound('G'); + static const const_iterator resultH = data.upper_bound('H'); + static const const_iterator resultI = data.upper_bound('I'); + static const const_iterator resultJ = data.upper_bound('J'); + static const const_iterator resultK = data.upper_bound('K'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); @@ -768,10 +760,10 @@ namespace { #ifdef TEST_GREATER_THAN static const Data data{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif static const size_t countA = data.count(Key('A')); @@ -804,10 +796,10 @@ namespace { #ifdef TEST_GREATER_THAN static const DataTransparentComparator data{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const DataTransparentComparator data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif static const size_t countA = data.count('A'); @@ -840,13 +832,13 @@ namespace { #ifdef TEST_GREATER_THAN static const Data data{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - Data::const_iterator itr = data.begin(); + const_iterator itr = data.begin(); #ifdef TEST_GREATER_THAN CHECK_TRUE((value_type{Key('J'), 9 }) == *itr++); @@ -880,22 +872,22 @@ namespace { #ifdef TEST_GREATER_THAN static const Data data{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static const Data::const_iterator resultA = data.find(Key('A')); - static const Data::const_iterator resultB = data.find(Key('B')); - static const Data::const_iterator resultC = data.find(Key('C')); - static const Data::const_iterator resultD = data.find(Key('D')); - static const Data::const_iterator resultE = data.find(Key('E')); - static const Data::const_iterator resultF = data.find(Key('F')); - static const Data::const_iterator resultG = data.find(Key('G')); - static const Data::const_iterator resultH = data.find(Key('H')); - static const Data::const_iterator resultI = data.find(Key('I')); - static const Data::const_iterator resultJ = data.find(Key('J')); + static const const_iterator resultA = data.find(Key('A')); + static const const_iterator resultB = data.find(Key('B')); + static const const_iterator resultC = data.find(Key('C')); + static const const_iterator resultD = data.find(Key('D')); + static const const_iterator resultE = data.find(Key('E')); + static const const_iterator resultF = data.find(Key('F')); + static const const_iterator resultG = data.find(Key('G')); + static const const_iterator resultH = data.find(Key('H')); + static const const_iterator resultI = data.find(Key('I')); + static const const_iterator resultJ = data.find(Key('J')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -927,22 +919,22 @@ namespace { #ifdef TEST_GREATER_THAN static const DataTransparentComparator data{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const DataTransparentComparator data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static const Data::const_iterator resultA = data.find('A'); - static const Data::const_iterator resultB = data.find('B'); - static const Data::const_iterator resultC = data.find('C'); - static const Data::const_iterator resultD = data.find('D'); - static const Data::const_iterator resultE = data.find('E'); - static const Data::const_iterator resultF = data.find('F'); - static const Data::const_iterator resultG = data.find('G'); - static const Data::const_iterator resultH = data.find('H'); - static const Data::const_iterator resultI = data.find('I'); - static const Data::const_iterator resultJ = data.find('J'); + static const const_iterator resultA = data.find('A'); + static const const_iterator resultB = data.find('B'); + static const const_iterator resultC = data.find('C'); + static const const_iterator resultD = data.find('D'); + static const const_iterator resultE = data.find('E'); + static const const_iterator resultF = data.find('F'); + static const const_iterator resultG = data.find('G'); + static const const_iterator resultH = data.find('H'); + static const const_iterator resultI = data.find('I'); + static const const_iterator resultJ = data.find('J'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -1031,10 +1023,10 @@ namespace { #ifdef TEST_GREATER_THAN static const Data data{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif static const bool containsA = data.contains(Key('A')); @@ -1067,10 +1059,10 @@ namespace { #ifdef TEST_GREATER_THAN static const DataTransparentComparator data{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const DataTransparentComparator data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif static const bool containsA = data.contains('A'); diff --git a/test/test_const_map_constexpr.cpp b/test/test_const_map_constexpr.cpp index 6296cf6c..43336dfa 100644 --- a/test/test_const_map_constexpr.cpp +++ b/test/test_const_map_constexpr.cpp @@ -35,6 +35,7 @@ SOFTWARE. #include #include #include +#include #include "etl/const_map.h" #include "etl/map.h" @@ -105,8 +106,10 @@ namespace using IDataTransparentComparator = etl::iconst_map>; #endif - using value_type = Data::value_type; - using Data_const_iterator = Data::const_iterator; + using value_type = Data::value_type; + using key_type = Data::key_type; + using mapped_type = Data::mapped_type; + using const_iterator = Data::const_iterator; SUITE(test_const_map) { @@ -115,14 +118,14 @@ namespace { static constexpr Data data; - static constexpr bool is_valid = data.is_valid(); - static constexpr size_t size = data.size(); - static constexpr bool empty = data.empty(); - static constexpr bool full = data.full(); - static constexpr size_t capacity = data.capacity(); - static constexpr size_t max_size = data.max_size(); - static constexpr Data::const_iterator begin = data.begin(); - static constexpr Data::const_iterator end = data.end(); + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == 0UL); @@ -138,14 +141,14 @@ namespace { static constexpr Data data{ value_type{Key('A'), 0 } }; - static constexpr bool is_valid = data.is_valid(); - static constexpr size_t size = data.size(); - static constexpr bool empty = data.empty(); - static constexpr bool full = data.full(); - static constexpr size_t capacity = data.capacity(); - static constexpr size_t max_size = data.max_size(); - static constexpr Data::const_iterator begin = data.begin(); - static constexpr Data::const_iterator end = data.end(); + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == 1U); @@ -167,14 +170,14 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr bool is_valid = data.is_valid(); - static constexpr size_t size = data.size(); - static constexpr bool empty = data.empty(); - static constexpr bool full = data.full(); - static constexpr size_t capacity = data.capacity(); - static constexpr size_t max_size = data.max_size(); - static constexpr Data::const_iterator begin = data.begin(); - static constexpr Data::const_iterator end = data.end(); + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == Max_Size); @@ -198,14 +201,14 @@ namespace static constexpr const IData& idata = data; - static constexpr bool is_valid = idata.is_valid(); - static constexpr size_t size = idata.size(); - static constexpr bool empty = idata.empty(); - static constexpr bool full = idata.full(); - static constexpr size_t capacity = idata.capacity(); - static constexpr size_t max_size = idata.max_size(); - static constexpr Data::const_iterator begin = idata.begin(); - static constexpr Data::const_iterator end = idata.end(); + static constexpr bool is_valid = idata.is_valid(); + static constexpr size_t size = idata.size(); + static constexpr bool empty = idata.empty(); + static constexpr bool full = idata.full(); + static constexpr size_t capacity = idata.capacity(); + static constexpr size_t max_size = idata.max_size(); + static constexpr const_iterator begin = idata.begin(); + static constexpr const_iterator end = idata.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == Max_Size); @@ -230,21 +233,11 @@ namespace //************************************************************************* TEST(test_cpp17_deduced_constructor) { -#ifdef TEST_GREATER_THAN - static constexpr Data data{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; -#else - static constexpr Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; -#endif - -#ifdef TEST_GREATER_THAN - etl::const_map check{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; -#else + static constexpr etl::const_map data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; etl::const_map check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; -#endif + CHECK_TRUE(data.is_valid()); CHECK_TRUE(data.size() == Max_Size); CHECK_FALSE(data.empty()); @@ -282,7 +275,7 @@ namespace static constexpr Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; - static constexpr Data::const_iterator end_itr = data.end(); + static constexpr const_iterator end_itr = data.end(); CHECK_TRUE(end_itr == (data.begin() + data.size())); } @@ -298,16 +291,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr Data::mapped_type atA = data[Key('A')]; - static constexpr Data::mapped_type atB = data[Key('B')]; - static constexpr Data::mapped_type atC = data[Key('C')]; - static constexpr Data::mapped_type atD = data[Key('D')]; - static constexpr Data::mapped_type atE = data[Key('E')]; - static constexpr Data::mapped_type atF = data[Key('F')]; - static constexpr Data::mapped_type atG = data[Key('G')]; - static constexpr Data::mapped_type atH = data[Key('H')]; - static constexpr Data::mapped_type atI = data[Key('I')]; - static constexpr Data::mapped_type atJ = data[Key('J')]; + static constexpr mapped_type atA = data[Key('A')]; + static constexpr mapped_type atB = data[Key('B')]; + static constexpr mapped_type atC = data[Key('C')]; + static constexpr mapped_type atD = data[Key('D')]; + static constexpr mapped_type atE = data[Key('E')]; + static constexpr mapped_type atF = data[Key('F')]; + static constexpr mapped_type atG = data[Key('G')]; + static constexpr mapped_type atH = data[Key('H')]; + static constexpr mapped_type atI = data[Key('I')]; + static constexpr mapped_type atJ = data[Key('J')]; CHECK_TRUE(data.is_valid()); CHECK(atA == 0); @@ -333,16 +326,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr Data::mapped_type atA = data['A']; - static constexpr Data::mapped_type atB = data['B']; - static constexpr Data::mapped_type atC = data['C']; - static constexpr Data::mapped_type atD = data['D']; - static constexpr Data::mapped_type atE = data['E']; - static constexpr Data::mapped_type atF = data['F']; - static constexpr Data::mapped_type atG = data['G']; - static constexpr Data::mapped_type atH = data['H']; - static constexpr Data::mapped_type atI = data['I']; - static constexpr Data::mapped_type atJ = data['J']; + static constexpr mapped_type atA = data['A']; + static constexpr mapped_type atB = data['B']; + static constexpr mapped_type atC = data['C']; + static constexpr mapped_type atD = data['D']; + static constexpr mapped_type atE = data['E']; + static constexpr mapped_type atF = data['F']; + static constexpr mapped_type atG = data['G']; + static constexpr mapped_type atH = data['H']; + static constexpr mapped_type atI = data['I']; + static constexpr mapped_type atJ = data['J']; CHECK_TRUE(data.is_valid()); CHECK(atA == 0); @@ -368,16 +361,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr Data::mapped_type atA = data.at(Key('A')); - static constexpr Data::mapped_type atB = data.at(Key('B')); - static constexpr Data::mapped_type atC = data.at(Key('C')); - static constexpr Data::mapped_type atD = data.at(Key('D')); - static constexpr Data::mapped_type atE = data.at(Key('E')); - static constexpr Data::mapped_type atF = data.at(Key('F')); - static constexpr Data::mapped_type atG = data.at(Key('G')); - static constexpr Data::mapped_type atH = data.at(Key('H')); - static constexpr Data::mapped_type atI = data.at(Key('I')); - static constexpr Data::mapped_type atJ = data.at(Key('J')); + static constexpr mapped_type atA = data.at(Key('A')); + static constexpr mapped_type atB = data.at(Key('B')); + static constexpr mapped_type atC = data.at(Key('C')); + static constexpr mapped_type atD = data.at(Key('D')); + static constexpr mapped_type atE = data.at(Key('E')); + static constexpr mapped_type atF = data.at(Key('F')); + static constexpr mapped_type atG = data.at(Key('G')); + static constexpr mapped_type atH = data.at(Key('H')); + static constexpr mapped_type atI = data.at(Key('I')); + static constexpr mapped_type atJ = data.at(Key('J')); CHECK_TRUE(data.is_valid()); CHECK(atA == 0); @@ -403,16 +396,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr Data::mapped_type atA = data.at('A'); - static constexpr Data::mapped_type atB = data.at('B'); - static constexpr Data::mapped_type atC = data.at('C'); - static constexpr Data::mapped_type atD = data.at('D'); - static constexpr Data::mapped_type atE = data.at('E'); - static constexpr Data::mapped_type atF = data.at('F'); - static constexpr Data::mapped_type atG = data.at('G'); - static constexpr Data::mapped_type atH = data.at('H'); - static constexpr Data::mapped_type atI = data.at('I'); - static constexpr Data::mapped_type atJ = data.at('J'); + static constexpr mapped_type atA = data.at('A'); + static constexpr mapped_type atB = data.at('B'); + static constexpr mapped_type atC = data.at('C'); + static constexpr mapped_type atD = data.at('D'); + static constexpr mapped_type atE = data.at('E'); + static constexpr mapped_type atF = data.at('F'); + static constexpr mapped_type atG = data.at('G'); + static constexpr mapped_type atH = data.at('H'); + static constexpr mapped_type atI = data.at('I'); + static constexpr mapped_type atJ = data.at('J'); CHECK_TRUE(data.is_valid()); CHECK(atA == 0); @@ -438,16 +431,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr ETL_OR_STD::pair resultA = data.equal_range(Key('A')); - static constexpr ETL_OR_STD::pair resultB = data.equal_range(Key('B')); - static constexpr ETL_OR_STD::pair resultC = data.equal_range(Key('C')); - static constexpr ETL_OR_STD::pair resultD = data.equal_range(Key('D')); - static constexpr ETL_OR_STD::pair resultE = data.equal_range(Key('E')); - static constexpr ETL_OR_STD::pair resultF = data.equal_range(Key('F')); - static constexpr ETL_OR_STD::pair resultG = data.equal_range(Key('G')); - static constexpr ETL_OR_STD::pair resultH = data.equal_range(Key('H')); - static constexpr ETL_OR_STD::pair resultI = data.equal_range(Key('I')); - static constexpr ETL_OR_STD::pair resultJ = data.equal_range(Key('J')); + static constexpr ETL_OR_STD::pair resultA = data.equal_range(Key('A')); + static constexpr ETL_OR_STD::pair resultB = data.equal_range(Key('B')); + static constexpr ETL_OR_STD::pair resultC = data.equal_range(Key('C')); + static constexpr ETL_OR_STD::pair resultD = data.equal_range(Key('D')); + static constexpr ETL_OR_STD::pair resultE = data.equal_range(Key('E')); + static constexpr ETL_OR_STD::pair resultF = data.equal_range(Key('F')); + static constexpr ETL_OR_STD::pair resultG = data.equal_range(Key('G')); + static constexpr ETL_OR_STD::pair resultH = data.equal_range(Key('H')); + static constexpr ETL_OR_STD::pair resultI = data.equal_range(Key('I')); + static constexpr ETL_OR_STD::pair resultJ = data.equal_range(Key('J')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); @@ -507,16 +500,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr ETL_OR_STD::pair resultA = data.equal_range('A'); - static constexpr ETL_OR_STD::pair resultB = data.equal_range('B'); - static constexpr ETL_OR_STD::pair resultC = data.equal_range('C'); - static constexpr ETL_OR_STD::pair resultD = data.equal_range('D'); - static constexpr ETL_OR_STD::pair resultE = data.equal_range('E'); - static constexpr ETL_OR_STD::pair resultF = data.equal_range('F'); - static constexpr ETL_OR_STD::pair resultG = data.equal_range('G'); - static constexpr ETL_OR_STD::pair resultH = data.equal_range('H'); - static constexpr ETL_OR_STD::pair resultI = data.equal_range('I'); - static constexpr ETL_OR_STD::pair resultJ = data.equal_range('J'); + static constexpr ETL_OR_STD::pair resultA = data.equal_range('A'); + static constexpr ETL_OR_STD::pair resultB = data.equal_range('B'); + static constexpr ETL_OR_STD::pair resultC = data.equal_range('C'); + static constexpr ETL_OR_STD::pair resultD = data.equal_range('D'); + static constexpr ETL_OR_STD::pair resultE = data.equal_range('E'); + static constexpr ETL_OR_STD::pair resultF = data.equal_range('F'); + static constexpr ETL_OR_STD::pair resultG = data.equal_range('G'); + static constexpr ETL_OR_STD::pair resultH = data.equal_range('H'); + static constexpr ETL_OR_STD::pair resultI = data.equal_range('I'); + static constexpr ETL_OR_STD::pair resultJ = data.equal_range('J'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); @@ -576,17 +569,17 @@ namespace value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; #endif - static constexpr Data::const_iterator resultA = data.lower_bound(Key('A')); - static constexpr Data::const_iterator resultB = data.lower_bound(Key('B')); - static constexpr Data::const_iterator resultC = data.lower_bound(Key('C')); - static constexpr Data::const_iterator resultD = data.lower_bound(Key('D')); - static constexpr Data::const_iterator resultE = data.lower_bound(Key('E')); - static constexpr Data::const_iterator resultF = data.lower_bound(Key('F')); - static constexpr Data::const_iterator resultG = data.lower_bound(Key('G')); - static constexpr Data::const_iterator resultH = data.lower_bound(Key('H')); - static constexpr Data::const_iterator resultI = data.lower_bound(Key('I')); - static constexpr Data::const_iterator resultJ = data.lower_bound(Key('J')); - static constexpr Data::const_iterator resultK = data.lower_bound(Key('K')); + static constexpr const_iterator resultA = data.lower_bound(Key('A')); + static constexpr const_iterator resultB = data.lower_bound(Key('B')); + static constexpr const_iterator resultC = data.lower_bound(Key('C')); + static constexpr const_iterator resultD = data.lower_bound(Key('D')); + static constexpr const_iterator resultE = data.lower_bound(Key('E')); + static constexpr const_iterator resultF = data.lower_bound(Key('F')); + static constexpr const_iterator resultG = data.lower_bound(Key('G')); + static constexpr const_iterator resultH = data.lower_bound(Key('H')); + static constexpr const_iterator resultI = data.lower_bound(Key('I')); + static constexpr const_iterator resultJ = data.lower_bound(Key('J')); + static constexpr const_iterator resultK = data.lower_bound(Key('K')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -626,17 +619,17 @@ namespace value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; #endif - static constexpr Data::const_iterator resultA = data.lower_bound('A'); - static constexpr Data::const_iterator resultB = data.lower_bound('B'); - static constexpr Data::const_iterator resultC = data.lower_bound('C'); - static constexpr Data::const_iterator resultD = data.lower_bound('D'); - static constexpr Data::const_iterator resultE = data.lower_bound('E'); - static constexpr Data::const_iterator resultF = data.lower_bound('F'); - static constexpr Data::const_iterator resultG = data.lower_bound('G'); - static constexpr Data::const_iterator resultH = data.lower_bound('H'); - static constexpr Data::const_iterator resultI = data.lower_bound('I'); - static constexpr Data::const_iterator resultJ = data.lower_bound('J'); - static constexpr Data::const_iterator resultK = data.lower_bound('K'); + static constexpr const_iterator resultA = data.lower_bound('A'); + static constexpr const_iterator resultB = data.lower_bound('B'); + static constexpr const_iterator resultC = data.lower_bound('C'); + static constexpr const_iterator resultD = data.lower_bound('D'); + static constexpr const_iterator resultE = data.lower_bound('E'); + static constexpr const_iterator resultF = data.lower_bound('F'); + static constexpr const_iterator resultG = data.lower_bound('G'); + static constexpr const_iterator resultH = data.lower_bound('H'); + static constexpr const_iterator resultI = data.lower_bound('I'); + static constexpr const_iterator resultJ = data.lower_bound('J'); + static constexpr const_iterator resultK = data.lower_bound('K'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -676,17 +669,17 @@ namespace value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; #endif - static constexpr Data::const_iterator resultA = data.upper_bound(Key('A')); - static constexpr Data::const_iterator resultB = data.upper_bound(Key('B')); - static constexpr Data::const_iterator resultC = data.upper_bound(Key('C')); - static constexpr Data::const_iterator resultD = data.upper_bound(Key('D')); - static constexpr Data::const_iterator resultE = data.upper_bound(Key('E')); - static constexpr Data::const_iterator resultF = data.upper_bound(Key('F')); - static constexpr Data::const_iterator resultG = data.upper_bound(Key('G')); - static constexpr Data::const_iterator resultH = data.upper_bound(Key('H')); - static constexpr Data::const_iterator resultI = data.upper_bound(Key('I')); - static constexpr Data::const_iterator resultJ = data.upper_bound(Key('J')); - static constexpr Data::const_iterator resultK = data.upper_bound(Key('K')); + static constexpr const_iterator resultA = data.upper_bound(Key('A')); + static constexpr const_iterator resultB = data.upper_bound(Key('B')); + static constexpr const_iterator resultC = data.upper_bound(Key('C')); + static constexpr const_iterator resultD = data.upper_bound(Key('D')); + static constexpr const_iterator resultE = data.upper_bound(Key('E')); + static constexpr const_iterator resultF = data.upper_bound(Key('F')); + static constexpr const_iterator resultG = data.upper_bound(Key('G')); + static constexpr const_iterator resultH = data.upper_bound(Key('H')); + static constexpr const_iterator resultI = data.upper_bound(Key('I')); + static constexpr const_iterator resultJ = data.upper_bound(Key('J')); + static constexpr const_iterator resultK = data.upper_bound(Key('K')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); @@ -726,17 +719,17 @@ namespace value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; #endif - static constexpr Data::const_iterator resultA = data.upper_bound('A'); - static constexpr Data::const_iterator resultB = data.upper_bound('B'); - static constexpr Data::const_iterator resultC = data.upper_bound('C'); - static constexpr Data::const_iterator resultD = data.upper_bound('D'); - static constexpr Data::const_iterator resultE = data.upper_bound('E'); - static constexpr Data::const_iterator resultF = data.upper_bound('F'); - static constexpr Data::const_iterator resultG = data.upper_bound('G'); - static constexpr Data::const_iterator resultH = data.upper_bound('H'); - static constexpr Data::const_iterator resultI = data.upper_bound('I'); - static constexpr Data::const_iterator resultJ = data.upper_bound('J'); - static constexpr Data::const_iterator resultK = data.upper_bound('K'); + static constexpr const_iterator resultA = data.upper_bound('A'); + static constexpr const_iterator resultB = data.upper_bound('B'); + static constexpr const_iterator resultC = data.upper_bound('C'); + static constexpr const_iterator resultD = data.upper_bound('D'); + static constexpr const_iterator resultE = data.upper_bound('E'); + static constexpr const_iterator resultF = data.upper_bound('F'); + static constexpr const_iterator resultG = data.upper_bound('G'); + static constexpr const_iterator resultH = data.upper_bound('H'); + static constexpr const_iterator resultI = data.upper_bound('I'); + static constexpr const_iterator resultJ = data.upper_bound('J'); + static constexpr const_iterator resultK = data.upper_bound('K'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); @@ -848,7 +841,7 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - Data::const_iterator itr = data.begin(); + const_iterator itr = data.begin(); #ifdef TEST_GREATER_THAN CHECK_TRUE((value_type{Key('J'), 9 }) == *itr++); @@ -888,16 +881,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr Data::const_iterator resultA = data.find(Key('A')); - static constexpr Data::const_iterator resultB = data.find(Key('B')); - static constexpr Data::const_iterator resultC = data.find(Key('C')); - static constexpr Data::const_iterator resultD = data.find(Key('D')); - static constexpr Data::const_iterator resultE = data.find(Key('E')); - static constexpr Data::const_iterator resultF = data.find(Key('F')); - static constexpr Data::const_iterator resultG = data.find(Key('G')); - static constexpr Data::const_iterator resultH = data.find(Key('H')); - static constexpr Data::const_iterator resultI = data.find(Key('I')); - static constexpr Data::const_iterator resultJ = data.find(Key('J')); + static constexpr const_iterator resultA = data.find(Key('A')); + static constexpr const_iterator resultB = data.find(Key('B')); + static constexpr const_iterator resultC = data.find(Key('C')); + static constexpr const_iterator resultD = data.find(Key('D')); + static constexpr const_iterator resultE = data.find(Key('E')); + static constexpr const_iterator resultF = data.find(Key('F')); + static constexpr const_iterator resultG = data.find(Key('G')); + static constexpr const_iterator resultH = data.find(Key('H')); + static constexpr const_iterator resultI = data.find(Key('I')); + static constexpr const_iterator resultJ = data.find(Key('J')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -935,16 +928,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr Data::const_iterator resultA = data.find('A'); - static constexpr Data::const_iterator resultB = data.find('B'); - static constexpr Data::const_iterator resultC = data.find('C'); - static constexpr Data::const_iterator resultD = data.find('D'); - static constexpr Data::const_iterator resultE = data.find('E'); - static constexpr Data::const_iterator resultF = data.find('F'); - static constexpr Data::const_iterator resultG = data.find('G'); - static constexpr Data::const_iterator resultH = data.find('H'); - static constexpr Data::const_iterator resultI = data.find('I'); - static constexpr Data::const_iterator resultJ = data.find('J'); + static constexpr const_iterator resultA = data.find('A'); + static constexpr const_iterator resultB = data.find('B'); + static constexpr const_iterator resultC = data.find('C'); + static constexpr const_iterator resultD = data.find('D'); + static constexpr const_iterator resultE = data.find('E'); + static constexpr const_iterator resultF = data.find('F'); + static constexpr const_iterator resultG = data.find('G'); + static constexpr const_iterator resultH = data.find('H'); + static constexpr const_iterator resultI = data.find('I'); + static constexpr const_iterator resultJ = data.find('J'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); diff --git a/test/test_const_map_ext.cpp b/test/test_const_map_ext.cpp new file mode 100644 index 00000000..7bded872 --- /dev/null +++ b/test/test_const_map_ext.cpp @@ -0,0 +1,1689 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2025 John Wellbelove, rlindeman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the 'Software'), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include "unit_test_framework.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "etl/const_map.h" +#include "etl/span.h" + +#include "data.h" + +namespace +{ + static const size_t Max_Size = 10UL; + + //************************************************************************* + // The key type + //************************************************************************* + struct Key + { + // Default constructor + constexpr Key() + : k(0) + { + } + + // Construct from char key + constexpr explicit Key(char k_) + : k(k_) + { + } + + char k; + }; + + // Less-than operator for Key < Key + constexpr bool operator <(const Key& lhs, const Key& rhs) noexcept + { + return (lhs.k < rhs.k); + } + + // Less-than operator for Key < char + constexpr bool operator <(const Key& lhs, char rhs) noexcept + { + return (lhs.k < rhs); + } + + // Less-than operator for char < Key + constexpr bool operator <(char lhs, const Key& rhs) noexcept + { + return (lhs < rhs.k); + } + + // Greater-than operator for char > Key + constexpr bool operator ==(const Key& lhs, const Key& rhs) noexcept + { + return (lhs.k == rhs.k); + } + + #define TEST_GREATER_THAN + #ifdef TEST_GREATER_THAN + using Data = etl::const_map_ext>; + using IData = etl::iconst_map>; + using DataTransparentComparator = etl::const_map_ext>; + using IDataTransparentComparator = etl::iconst_map>; + #else + using Data = etl::const_map>; + using IData = etl::iconst_map>; + using DataTransparentComparator = etl::const_map>; + using IDataTransparentComparator = etl::iconst_map>; + #endif + + using value_type = Data::value_type; + using key_type = Data::key_type; + using mapped_type = Data::mapped_type; + using const_iterator = Data::const_iterator; + using span_type = etl::span; + + SUITE(test_const_map) + { + //************************************************************************* + TEST(test_default_constructor) + { + static const Data data; + + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == 0UL); + CHECK_TRUE(empty); + CHECK_FALSE(full); + CHECK_TRUE(capacity == 0); + CHECK_TRUE(max_size == 0); + CHECK_TRUE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_min_size_from_span) + { + static const value_type values[]{value_type{Key('A'), 0}}; + static const etl::span span(values); + static const Data data{ span }; + + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == 1U); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == span.size()); + CHECK_TRUE(max_size == span.size()); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_max_size_from_span) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const span_type span(values); + static const Data data{ span }; + + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == Max_Size); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == Max_Size); + CHECK_TRUE(max_size == Max_Size); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_max_size_from_array) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == Max_Size); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == Max_Size); + CHECK_TRUE(max_size == Max_Size); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_max_size_status_from_iconst_map) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const IData& idata = data; + + static const bool is_valid = idata.is_valid(); + static const size_t size = idata.size(); + static const bool empty = idata.empty(); + static const bool full = idata.full(); + static const size_t capacity = idata.capacity(); + static const size_t max_size = idata.max_size(); + static const const_iterator begin = idata.begin(); + static const const_iterator end = idata.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == Max_Size); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == Max_Size); + CHECK_TRUE(max_size == Max_Size); + CHECK_FALSE(begin == end); + } + +#if ETL_USING_CPP17 + //************************************************************************* + TEST(test_cpp17_deduced_constructor_from_span) + { + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const span_type span(values); + static const etl::const_map_ext data{span}; + + etl::const_map check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + CHECK_TRUE(data.is_valid()); + CHECK_TRUE(data.size() == Max_Size); + CHECK_FALSE(data.empty()); + CHECK_TRUE(data.full()); + CHECK_TRUE(data.capacity() == Max_Size); + CHECK_TRUE(data.max_size() == Max_Size); + CHECK_FALSE(data.begin() == data.end()); + } + + //************************************************************************* + TEST(test_cpp17_deduced_constructor_from_array) + { + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const etl::const_map_ext data{values}; + + etl::const_map check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + CHECK_TRUE(data.is_valid()); + CHECK_TRUE(data.size() == Max_Size); + CHECK_FALSE(data.empty()); + CHECK_TRUE(data.full()); + CHECK_TRUE(data.capacity() == Max_Size); + CHECK_TRUE(data.max_size() == Max_Size); + CHECK_FALSE(data.begin() == data.end()); + } +#endif + + //************************************************************************* + TEST(test_begin) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + CHECK_TRUE(data.is_valid()); + static const auto value = *data.begin(); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE((value_type{ Key('J'), 9 }) == value); +#else + CHECK_TRUE((value_type{ Key('A'), 0 }) == value); +#endif + } + + //************************************************************************* + TEST(test_end) + { + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + + static const Data data{ values }; + + static const const_iterator end_itr = data.end(); + + CHECK_TRUE(end_itr == (data.begin() + data.size())); + } + + //************************************************************************* + TEST(test_index) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const mapped_type atA = data[Key('A')]; + static const mapped_type atB = data[Key('B')]; + static const mapped_type atC = data[Key('C')]; + static const mapped_type atD = data[Key('D')]; + static const mapped_type atE = data[Key('E')]; + static const mapped_type atF = data[Key('F')]; + static const mapped_type atG = data[Key('G')]; + static const mapped_type atH = data[Key('H')]; + static const mapped_type atI = data[Key('I')]; + static const mapped_type atJ = data[Key('J')]; + + CHECK_TRUE(data.is_valid()); + CHECK(atA == 0); + CHECK(atB == 1); + CHECK(atC == 2); + CHECK(atD == 3); + CHECK(atE == 4); + CHECK(atF == 5); + CHECK(atG == 6); + CHECK(atH == 7); + CHECK(atI == 8); + CHECK(atJ == 9); + } + + //************************************************************************* + TEST(test_index_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const mapped_type atA = data['A']; + static const mapped_type atB = data['B']; + static const mapped_type atC = data['C']; + static const mapped_type atD = data['D']; + static const mapped_type atE = data['E']; + static const mapped_type atF = data['F']; + static const mapped_type atG = data['G']; + static const mapped_type atH = data['H']; + static const mapped_type atI = data['I']; + static const mapped_type atJ = data['J']; + + CHECK_TRUE(data.is_valid()); + CHECK(atA == 0); + CHECK(atB == 1); + CHECK(atC == 2); + CHECK(atD == 3); + CHECK(atE == 4); + CHECK(atF == 5); + CHECK(atG == 6); + CHECK(atH == 7); + CHECK(atI == 8); + CHECK(atJ == 9); + } + + //************************************************************************* + TEST(test_at) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const mapped_type atA = data.at(Key('A')); + static const mapped_type atB = data.at(Key('B')); + static const mapped_type atC = data.at(Key('C')); + static const mapped_type atD = data.at(Key('D')); + static const mapped_type atE = data.at(Key('E')); + static const mapped_type atF = data.at(Key('F')); + static const mapped_type atG = data.at(Key('G')); + static const mapped_type atH = data.at(Key('H')); + static const mapped_type atI = data.at(Key('I')); + static const mapped_type atJ = data.at(Key('J')); + + CHECK_TRUE(data.is_valid()); + CHECK(atA == 0); + CHECK(atB == 1); + CHECK(atC == 2); + CHECK(atD == 3); + CHECK(atE == 4); + CHECK(atF == 5); + CHECK(atG == 6); + CHECK(atH == 7); + CHECK(atI == 8); + CHECK(atJ == 9); + } + + //************************************************************************* + TEST(test_at_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const mapped_type atA = data.at('A'); + static const mapped_type atB = data.at('B'); + static const mapped_type atC = data.at('C'); + static const mapped_type atD = data.at('D'); + static const mapped_type atE = data.at('E'); + static const mapped_type atF = data.at('F'); + static const mapped_type atG = data.at('G'); + static const mapped_type atH = data.at('H'); + static const mapped_type atI = data.at('I'); + static const mapped_type atJ = data.at('J'); + + CHECK_TRUE(data.is_valid()); + CHECK(atA == 0); + CHECK(atB == 1); + CHECK(atC == 2); + CHECK(atD == 3); + CHECK(atE == 4); + CHECK(atF == 5); + CHECK(atG == 6); + CHECK(atH == 7); + CHECK(atI == 8); + CHECK(atJ == 9); + } + + //************************************************************************* + TEST(test_equal_range) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const ETL_OR_STD::pair resultA = data.equal_range(Key('A')); + static const ETL_OR_STD::pair resultB = data.equal_range(Key('B')); + static const ETL_OR_STD::pair resultC = data.equal_range(Key('C')); + static const ETL_OR_STD::pair resultD = data.equal_range(Key('D')); + static const ETL_OR_STD::pair resultE = data.equal_range(Key('E')); + static const ETL_OR_STD::pair resultF = data.equal_range(Key('F')); + static const ETL_OR_STD::pair resultG = data.equal_range(Key('G')); + static const ETL_OR_STD::pair resultH = data.equal_range(Key('H')); + static const ETL_OR_STD::pair resultI = data.equal_range(Key('I')); + static const ETL_OR_STD::pair resultJ = data.equal_range(Key('J')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(10, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ.second))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(1, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultJ.second))); +#endif + } + + //************************************************************************* + TEST(test_equal_range_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const ETL_OR_STD::pair resultA = data.equal_range('A'); + static const ETL_OR_STD::pair resultB = data.equal_range('B'); + static const ETL_OR_STD::pair resultC = data.equal_range('C'); + static const ETL_OR_STD::pair resultD = data.equal_range('D'); + static const ETL_OR_STD::pair resultE = data.equal_range('E'); + static const ETL_OR_STD::pair resultF = data.equal_range('F'); + static const ETL_OR_STD::pair resultG = data.equal_range('G'); + static const ETL_OR_STD::pair resultH = data.equal_range('H'); + static const ETL_OR_STD::pair resultI = data.equal_range('I'); + static const ETL_OR_STD::pair resultJ = data.equal_range('J'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(10, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ.second))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(1, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultJ.second))); +#endif + } + + //************************************************************************* + TEST(test_lower_bound) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('K'), 10 }, value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, + value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, + value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; +#endif + + static const Data data{ values }; + + static const const_iterator resultA = data.lower_bound(Key('A')); + static const const_iterator resultB = data.lower_bound(Key('B')); + static const const_iterator resultC = data.lower_bound(Key('C')); + static const const_iterator resultD = data.lower_bound(Key('D')); + static const const_iterator resultE = data.lower_bound(Key('E')); + static const const_iterator resultF = data.lower_bound(Key('F')); + static const const_iterator resultG = data.lower_bound(Key('G')); + static const const_iterator resultH = data.lower_bound(Key('H')); + static const const_iterator resultI = data.lower_bound(Key('I')); + static const const_iterator resultJ = data.lower_bound(Key('J')); + static const const_iterator resultK = data.lower_bound(Key('K')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_lower_bound_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('K'), 10 }, value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, + value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, + value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const const_iterator resultA = data.lower_bound('A'); + static const const_iterator resultB = data.lower_bound('B'); + static const const_iterator resultC = data.lower_bound('C'); + static const const_iterator resultD = data.lower_bound('D'); + static const const_iterator resultE = data.lower_bound('E'); + static const const_iterator resultF = data.lower_bound('F'); + static const const_iterator resultG = data.lower_bound('G'); + static const const_iterator resultH = data.lower_bound('H'); + static const const_iterator resultI = data.lower_bound('I'); + static const const_iterator resultJ = data.lower_bound('J'); + static const const_iterator resultK = data.lower_bound('K'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_upper_bound) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('K'), 10 }, value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, + value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, + value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; +#endif + + static const Data data{ values }; + + static const const_iterator resultA = data.upper_bound(Key('A')); + static const const_iterator resultB = data.upper_bound(Key('B')); + static const const_iterator resultC = data.upper_bound(Key('C')); + static const const_iterator resultD = data.upper_bound(Key('D')); + static const const_iterator resultE = data.upper_bound(Key('E')); + static const const_iterator resultF = data.upper_bound(Key('F')); + static const const_iterator resultG = data.upper_bound(Key('G')); + static const const_iterator resultH = data.upper_bound(Key('H')); + static const const_iterator resultI = data.upper_bound(Key('I')); + static const const_iterator resultJ = data.upper_bound(Key('J')); + static const const_iterator resultK = data.upper_bound(Key('K')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(1, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_upper_bound_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('K'), 10 }, value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, + value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, + value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const const_iterator resultA = data.upper_bound('A'); + static const const_iterator resultB = data.upper_bound('B'); + static const const_iterator resultC = data.upper_bound('C'); + static const const_iterator resultD = data.upper_bound('D'); + static const const_iterator resultE = data.upper_bound('E'); + static const const_iterator resultF = data.upper_bound('F'); + static const const_iterator resultG = data.upper_bound('G'); + static const const_iterator resultH = data.upper_bound('H'); + static const const_iterator resultI = data.upper_bound('I'); + static const const_iterator resultJ = data.upper_bound('J'); + static const const_iterator resultK = data.upper_bound('K'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(1, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_count) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const size_t countA = data.count(Key('A')); + static const size_t countB = data.count(Key('B')); + static const size_t countC = data.count(Key('C')); + static const size_t countD = data.count(Key('D')); + static const size_t countE = data.count(Key('E')); + static const size_t countF = data.count(Key('F')); + static const size_t countG = data.count(Key('G')); + static const size_t countH = data.count(Key('H')); + static const size_t countI = data.count(Key('I')); + static const size_t countJ = data.count(Key('J')); + static const size_t countK = data.count(Key('K')); + + CHECK_EQUAL(1, countA); + CHECK_EQUAL(1, countB); + CHECK_EQUAL(1, countC); + CHECK_EQUAL(1, countD); + CHECK_EQUAL(1, countE); + CHECK_EQUAL(1, countF); + CHECK_EQUAL(1, countG); + CHECK_EQUAL(1, countH); + CHECK_EQUAL(1, countI); + CHECK_EQUAL(1, countJ); + CHECK_EQUAL(0, countK); + } + + //************************************************************************* + TEST(test_count_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const size_t countA = data.count('A'); + static const size_t countB = data.count('B'); + static const size_t countC = data.count('C'); + static const size_t countD = data.count('D'); + static const size_t countE = data.count('E'); + static const size_t countF = data.count('F'); + static const size_t countG = data.count('G'); + static const size_t countH = data.count('H'); + static const size_t countI = data.count('I'); + static const size_t countJ = data.count('J'); + static const size_t countK = data.count('K'); + + CHECK_EQUAL(1, countA); + CHECK_EQUAL(1, countB); + CHECK_EQUAL(1, countC); + CHECK_EQUAL(1, countD); + CHECK_EQUAL(1, countE); + CHECK_EQUAL(1, countF); + CHECK_EQUAL(1, countG); + CHECK_EQUAL(1, countH); + CHECK_EQUAL(1, countI); + CHECK_EQUAL(1, countJ); + CHECK_EQUAL(0, countK); + } + + //************************************************************************* + TEST(test_const_iterator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + const_iterator itr = data.begin(); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE((value_type{Key('J'), 9 }) == *itr++); + CHECK_TRUE((value_type{Key('I'), 8 }) == *itr++); + CHECK_TRUE((value_type{Key('H'), 7 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 6 }) == *itr++); + CHECK_TRUE((value_type{Key('F'), 5 }) == *itr++); + CHECK_TRUE((value_type{Key('E'), 4 }) == *itr++); + CHECK_TRUE((value_type{Key('D'), 3 }) == *itr++); + CHECK_TRUE((value_type{Key('C'), 2 }) == *itr++); + CHECK_TRUE((value_type{Key('B'), 1 }) == *itr++); + CHECK_TRUE((value_type{Key('A'), 0 }) == *itr++); + CHECK_TRUE(itr == data.end()); +#else + CHECK_TRUE((value_type{Key('A'), 0 }) == *itr++); + CHECK_TRUE((value_type{Key('B'), 1 }) == *itr++); + CHECK_TRUE((value_type{Key('C'), 2 }) == *itr++); + CHECK_TRUE((value_type{Key('D'), 3 }) == *itr++); + CHECK_TRUE((value_type{Key('E'), 4 }) == *itr++); + CHECK_TRUE((value_type{Key('F'), 5 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 6 }) == *itr++); + CHECK_TRUE((value_type{Key('H'), 7 }) == *itr++); + CHECK_TRUE((value_type{Key('I'), 8 }) == *itr++); + CHECK_TRUE((value_type{Key('J'), 9 }) == *itr++); + CHECK_TRUE(itr == data.end()); +#endif + } + + //************************************************************************* + TEST(test_find) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const const_iterator resultA = data.find(Key('A')); + static const const_iterator resultB = data.find(Key('B')); + static const const_iterator resultC = data.find(Key('C')); + static const const_iterator resultD = data.find(Key('D')); + static const const_iterator resultE = data.find(Key('E')); + static const const_iterator resultF = data.find(Key('F')); + static const const_iterator resultG = data.find(Key('G')); + static const const_iterator resultH = data.find(Key('H')); + static const const_iterator resultI = data.find(Key('I')); + static const const_iterator resultJ = data.find(Key('J')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); +#endif + } + + //************************************************************************* + TEST(test_find_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const const_iterator resultA = data.find('A'); + static const const_iterator resultB = data.find('B'); + static const const_iterator resultC = data.find('C'); + static const const_iterator resultD = data.find('D'); + static const const_iterator resultE = data.find('E'); + static const const_iterator resultF = data.find('F'); + static const const_iterator resultG = data.find('G'); + static const const_iterator resultH = data.find('H'); + static const const_iterator resultI = data.find('I'); + static const const_iterator resultJ = data.find('J'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); +#endif + } + + //************************************************************************* + TEST(test_key_compare) + { + static const Data data; + + static const Data::key_compare compare = data.key_comp(); + + static const Data::key_type a(Key('A')); + static const Data::key_type b(Key('B')); + +#ifdef TEST_GREATER_THAN + CHECK(!compare(a, b)); + CHECK(compare(b, a)); +#else + CHECK(compare(a, b)); + CHECK(!compare(b, a)); +#endif + } + + //************************************************************************* + TEST(test_key_compare_using_transparent_comparator) + { + static const DataTransparentComparator data; + static const DataTransparentComparator::key_compare compare = data.key_comp(); + + static const DataTransparentComparator::key_type a(Key('A')); + static const DataTransparentComparator::key_type b(Key('B')); + +#ifdef TEST_GREATER_THAN + CHECK(!compare(a, b)); + CHECK(compare(b, a)); +#else + CHECK(compare(a, b)); + CHECK(!compare(b, a)); +#endif + } + + //************************************************************************* + TEST(test_value_compare) + { + static const Data data; + static const Data::value_compare compare = data.value_comp(); + + static const Data::value_type a(Key('A'), 0); + static const Data::value_type b(Key('B'), 1); + +#ifdef TEST_GREATER_THAN + CHECK(!compare(a, b)); + CHECK(compare(b, a)); +#else + CHECK(compare(a, b)); + CHECK(!compare(b, a)); +#endif + } + + //************************************************************************* + TEST(test_contains) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const bool containsA = data.contains(Key('A')); + static const bool containsB = data.contains(Key('B')); + static const bool containsC = data.contains(Key('C')); + static const bool containsD = data.contains(Key('D')); + static const bool containsE = data.contains(Key('E')); + static const bool containsF = data.contains(Key('F')); + static const bool containsG = data.contains(Key('G')); + static const bool containsH = data.contains(Key('H')); + static const bool containsI = data.contains(Key('I')); + static const bool containsJ = data.contains(Key('J')); + static const bool containsK = data.contains(Key('K')); + + CHECK_TRUE(containsA); + CHECK_TRUE(containsB); + CHECK_TRUE(containsC); + CHECK_TRUE(containsD); + CHECK_TRUE(containsE); + CHECK_TRUE(containsF); + CHECK_TRUE(containsG); + CHECK_TRUE(containsH); + CHECK_TRUE(containsI); + CHECK_TRUE(containsJ); + CHECK_FALSE(containsK); + } + + //************************************************************************* + TEST(test_contains_with_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const bool containsA = data.contains('A'); + static const bool containsB = data.contains('B'); + static const bool containsC = data.contains('C'); + static const bool containsD = data.contains('D'); + static const bool containsE = data.contains('E'); + static const bool containsF = data.contains('F'); + static const bool containsG = data.contains('G'); + static const bool containsH = data.contains('H'); + static const bool containsI = data.contains('I'); + static const bool containsJ = data.contains('J'); + static const bool containsK = data.contains('K'); + + CHECK_TRUE(containsA); + CHECK_TRUE(containsB); + CHECK_TRUE(containsC); + CHECK_TRUE(containsD); + CHECK_TRUE(containsE); + CHECK_TRUE(containsF); + CHECK_TRUE(containsG); + CHECK_TRUE(containsH); + CHECK_TRUE(containsI); + CHECK_TRUE(containsJ); + CHECK_FALSE(containsK); + } + + //************************************************************************* + TEST(test_key_comp) + { + static const Data data; + static const Data::key_compare compare = data.key_comp(); + + static const bool compareAA = compare(Key{ 'A' }, Key{ 'A' }); + static const bool compareBA = compare(Key{ 'B' }, Key{ 'A' }); + static const bool compareAB = compare(Key{ 'A' }, Key{ 'B' }); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA); + CHECK_TRUE(compareBA); + CHECK_FALSE(compareAB); +#else + CHECK_FALSE(compareAA); + CHECK_FALSE(compareBA); + CHECK_TRUE(compareAB); +#endif + } + + //************************************************************************* + TEST(test_key_comp_transparent_comparator) + { + static const DataTransparentComparator data; + static const DataTransparentComparator::key_compare compare = data.key_comp(); + + static const bool compareAA = compare('A', 'A'); + static const bool compareBA = compare('B', 'A'); + static const bool compareAB = compare('A', 'B'); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA); + CHECK_TRUE(compareBA); + CHECK_FALSE(compareAB); +#else + CHECK_FALSE(compareAA); + CHECK_FALSE(compareBA); + CHECK_TRUE(compareAB); +#endif + } + + //************************************************************************* + TEST(test_value_comp) + { + static const Data data; + static const Data::value_compare compare = data.value_comp(); + + static const bool compareAA1 = compare(value_type{ Key{ 'A' }, 0 }, value_type{ Key{ 'A' }, 0 }); + static const bool compareAA2 = compare(value_type{ Key{ 'A' }, 0 }, Key{ 'A' }); + static const bool compareAA3 = compare(Key{ 'A' }, value_type{ Key{ 'A' }, 0 }); + + static const bool compareBA1 = compare(value_type{ Key{ 'B' }, 0 }, value_type{ Key{ 'A' }, 0 }); + static const bool compareBA2 = compare(value_type{ Key{ 'B' }, 0 }, Key{ 'A' }); + static const bool compareBA3 = compare(Key{ 'B' }, value_type{ Key{ 'A' }, 0 }); + + static const bool compareAB1 = compare(value_type{ Key{ 'A' }, 0 }, value_type{ Key{ 'B' }, 0 }); + static const bool compareAB2 = compare(value_type{ Key{ 'A' }, 0 }, Key{ 'B' }); + static const bool compareAB3 = compare(Key{ 'A' }, value_type{ Key{ 'B' }, 0 });; + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_TRUE(compareBA1); + CHECK_TRUE(compareBA2); + CHECK_TRUE(compareBA3); + + CHECK_FALSE(compareAB1); + CHECK_FALSE(compareAB2); + CHECK_FALSE(compareAB3); +#else + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_FALSE(compareBA1); + CHECK_FALSE(compareBA2); + CHECK_FALSE(compareBA3); + + CHECK_TRUE(compareAB1); + CHECK_TRUE(compareAB2); + CHECK_TRUE(compareAB3); +#endif + } + + //************************************************************************* + TEST(test_value_comp_transparent_comparator) + { + static const DataTransparentComparator data; + static const DataTransparentComparator::value_compare compare = data.value_comp(); + + static const bool compareAA1 = compare(value_type{ 'A', 0 }, value_type{ 'A', 0 }); + static const bool compareAA2 = compare(value_type{ 'A', 0 }, 'A'); + static const bool compareAA3 = compare('A', value_type{ 'A', 0 }); + + static const bool compareBA1 = compare(value_type{ 'B', 0 }, value_type{ 'A', 0 }); + static const bool compareBA2 = compare(value_type{ 'B', 0 }, 'A'); + static const bool compareBA3 = compare('B', value_type{ 'A', 0 }); + + static const bool compareAB1 = compare(value_type{ 'A', 0 }, value_type{ 'B', 0 }); + static const bool compareAB2 = compare(value_type{ 'A', 0 }, 'B'); + static const bool compareAB3 = compare('A', value_type{ 'B', 0 });; + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_TRUE(compareBA1); + CHECK_TRUE(compareBA2); + CHECK_TRUE(compareBA3); + + CHECK_FALSE(compareAB1); + CHECK_FALSE(compareAB2); + CHECK_FALSE(compareAB3); +#else + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_FALSE(compareBA1); + CHECK_FALSE(compareBA2); + CHECK_FALSE(compareBA3); + + CHECK_TRUE(compareAB1); + CHECK_TRUE(compareAB2); + CHECK_TRUE(compareAB3); +#endif + } + + //************************************************************************* + TEST(test_equal) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data1{values1}; + static const Data data2{values2}; + static const Data data3{values3}; + + static const bool equal12 = (data1 == data2); + static const bool equal13 = (data1 == data3); + + CHECK_TRUE(equal12); + CHECK_FALSE(equal13); + } + + //************************************************************************* + TEST(test_equal_with_transparent_comparator) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const DataTransparentComparator data1{values1}; + static const DataTransparentComparator data2{values2}; + static const DataTransparentComparator data3{values3}; + + static const bool equal12 = (data1 == data2); + static const bool equal13 = (data1 == data3); + + CHECK_TRUE(equal12); + CHECK_FALSE(equal13); + } + + //************************************************************************* + TEST(test_not_equal) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data1{values1}; + static const Data data2{values2}; + static const Data data3{values3}; + + static const bool not_equal12 = (data1 != data2); + static const bool not_equal13 = (data1 != data3); + + CHECK_FALSE(not_equal12); + CHECK_TRUE(not_equal13); + } + + //************************************************************************* + TEST(test_not_equal_with_transparent_comparator) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const DataTransparentComparator data1{values1}; + static const DataTransparentComparator data2{values2}; + static const DataTransparentComparator data3{values3}; + + static const bool not_equal12 = (data1 != data2); + static const bool not_equal13 = (data1 != data3); + + CHECK_FALSE(not_equal12); + CHECK_TRUE(not_equal13); + } + + //************************************************************************* + TEST(test_less_than) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data1{values1}; + static const Data data2{values2}; + static const Data data3{values3}; + + static const bool less_than12 = (data1 < data2); + static const bool less_than23 = (data2 < data3); + static const bool less_than21 = (data2 < data1); + static const bool less_than32 = (data3 < data2); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than12); + CHECK_FALSE(less_than23); + CHECK_TRUE(less_than21); + CHECK_TRUE(less_than32); +#else + CHECK_TRUE(less_than12); + CHECK_TRUE(less_than23); + CHECK_FALSE(less_than21); + CHECK_FALSE(less_than32); +#endif + } + + //************************************************************************* + TEST(test_less_than_with_transparent_comparator) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const DataTransparentComparator data1{values1}; + static const DataTransparentComparator data2{values2}; + static const DataTransparentComparator data3{values3}; + + static const bool less_than12 = (data1 < data2); + static const bool less_than23 = (data2 < data3); + static const bool less_than21 = (data2 < data1); + static const bool less_than32 = (data3 < data2); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than12); + CHECK_FALSE(less_than23); + CHECK_TRUE(less_than21); + CHECK_TRUE(less_than32); +#else + CHECK_TRUE(less_than12); + CHECK_TRUE(less_than23); + CHECK_FALSE(less_than21); + CHECK_FALSE(less_than32); +#endif + } + + //************************************************************************* + TEST(test_less_than_equal) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data1{values1}; + static const Data data2{values2}; + static const Data data3{values3}; + + static const bool less_than_equal12 = (data1 <= data2); + static const bool less_than_equal23 = (data2 <= data3); + static const bool less_than_equal21 = (data2 <= data1); + static const bool less_than_equal32 = (data3 <= data2); + static const bool less_than_equal11 = (data1 <= data1); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than_equal12); + CHECK_FALSE(less_than_equal23); + CHECK_TRUE(less_than_equal21); + CHECK_TRUE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#else + CHECK_TRUE(less_than_equal12); + CHECK_TRUE(less_than_equal23); + CHECK_FALSE(less_than_equal21); + CHECK_FALSE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#endif + } + + //************************************************************************* + TEST(test_less_than_equal_with_transparent_comparator) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const DataTransparentComparator data1{values1}; + static const DataTransparentComparator data2{values2}; + static const DataTransparentComparator data3{values3}; + + static const bool less_than_equal12 = (data1 <= data2); + static const bool less_than_equal23 = (data2 <= data3); + static const bool less_than_equal21 = (data2 <= data1); + static const bool less_than_equal32 = (data3 <= data2); + static const bool less_than_equal11 = (data1 <= data1); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than_equal12); + CHECK_FALSE(less_than_equal23); + CHECK_TRUE(less_than_equal21); + CHECK_TRUE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#else + CHECK_TRUE(less_than_equal12); + CHECK_TRUE(less_than_equal23); + CHECK_FALSE(less_than_equal21); + CHECK_FALSE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#endif + } + + //************************************************************************* + TEST(test_greater_than) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data1{values1}; + static const Data data2{values2}; + static const Data data3{values3}; + + static const bool greater_than12 = (data1 > data2); + static const bool greater_than23 = (data2 > data3); + static const bool greater_than21 = (data2 > data1); + static const bool greater_than32 = (data3 > data2); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than12); + CHECK_TRUE(greater_than23); + CHECK_FALSE(greater_than21); + CHECK_FALSE(greater_than32); +#else + CHECK_FALSE(greater_than12); + CHECK_FALSE(greater_than23); + CHECK_TRUE(greater_than21); + CHECK_TRUE(greater_than32); +#endif + } + + //************************************************************************* + TEST(test_greater_than_with_transparent_comparator) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const DataTransparentComparator data1{values1}; + static const DataTransparentComparator data2{values2}; + static const DataTransparentComparator data3{values3}; + + static const bool greater_than12 = (data1 > data2); + static const bool greater_than23 = (data2 > data3); + static const bool greater_than21 = (data2 > data1); + static const bool greater_than32 = (data3 > data2); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than12); + CHECK_TRUE(greater_than23); + CHECK_FALSE(greater_than21); + CHECK_FALSE(greater_than32); +#else + CHECK_FALSE(greater_than12); + CHECK_FALSE(greater_than23); + CHECK_TRUE(greater_than21); + CHECK_TRUE(greater_than32); +#endif + } + + //************************************************************************* + TEST(test_greater_than_equal) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data1{values1}; + static const Data data2{values2}; + static const Data data3{values3}; + + static const bool greater_than_equal12 = (data1 >= data2); + static const bool greater_than_equal23 = (data2 >= data3); + static const bool greater_than_equal21 = (data2 >= data1); + static const bool greater_than_equal32 = (data3 >= data2); + static const bool greater_than_equal11 = (data1 >= data1); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than_equal12); + CHECK_TRUE(greater_than_equal23); + CHECK_FALSE(greater_than_equal21); + CHECK_FALSE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#else + CHECK_FALSE(greater_than_equal12); + CHECK_FALSE(greater_than_equal23); + CHECK_TRUE(greater_than_equal21); + CHECK_TRUE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#endif + } + + //************************************************************************* + TEST(test_greater_than_equal_with_transparent_comparator) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const DataTransparentComparator data1{values1}; + static const DataTransparentComparator data2{values2}; + static const DataTransparentComparator data3{values3}; + + static const bool greater_than_equal12 = (data1 >= data2); + static const bool greater_than_equal23 = (data2 >= data3); + static const bool greater_than_equal21 = (data2 >= data1); + static const bool greater_than_equal32 = (data3 >= data2); + static const bool greater_than_equal11 = (data1 >= data1); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than_equal12); + CHECK_TRUE(greater_than_equal23); + CHECK_FALSE(greater_than_equal21); + CHECK_FALSE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#else + CHECK_FALSE(greater_than_equal12); + CHECK_FALSE(greater_than_equal23); + CHECK_TRUE(greater_than_equal21); + CHECK_TRUE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#endif + } + }; +} diff --git a/test/test_const_map_ext_constexpr.cpp b/test/test_const_map_ext_constexpr.cpp new file mode 100644 index 00000000..61816dd0 --- /dev/null +++ b/test/test_const_map_ext_constexpr.cpp @@ -0,0 +1,1689 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2025 John Wellbelove, rlindeman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the 'Software'), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include "unit_test_framework.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "etl/const_map.h" +#include "etl/span.h" + +#include "data.h" + +namespace +{ + static constexpr size_t Max_Size = 10UL; + + //************************************************************************* + // The key type + //************************************************************************* + struct Key + { + // Default constructor + constexpr Key() + : k(0) + { + } + + // Construct from char key + constexpr explicit Key(char k_) + : k(k_) + { + } + + char k; + }; + + // Less-than operator for Key < Key + constexpr bool operator <(const Key& lhs, const Key& rhs) noexcept + { + return (lhs.k < rhs.k); + } + + // Less-than operator for Key < char + constexpr bool operator <(const Key& lhs, char rhs) noexcept + { + return (lhs.k < rhs); + } + + // Less-than operator for char < Key + constexpr bool operator <(char lhs, const Key& rhs) noexcept + { + return (lhs < rhs.k); + } + + // Greater-than operator for char > Key + constexpr bool operator ==(const Key& lhs, const Key& rhs) noexcept + { + return (lhs.k == rhs.k); + } + + #define TEST_GREATER_THAN + #ifdef TEST_GREATER_THAN + using Data = etl::const_map_ext>; + using IData = etl::iconst_map>; + using DataTransparentComparator = etl::const_map_ext>; + using IDataTransparentComparator = etl::iconst_map>; + #else + using Data = etl::const_map>; + using IData = etl::iconst_map>; + using DataTransparentComparator = etl::const_map>; + using IDataTransparentComparator = etl::iconst_map>; + #endif + + using value_type = Data::value_type; + using key_type = Data::key_type; + using mapped_type = Data::mapped_type; + using const_iterator = Data::const_iterator; + using span_type = etl::span; + + SUITE(test_const_map) + { + //************************************************************************* + TEST(test_default_constructor) + { + static constexpr Data data; + + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == 0UL); + CHECK_TRUE(empty); + CHECK_FALSE(full); + CHECK_TRUE(capacity == 0); + CHECK_TRUE(max_size == 0); + CHECK_TRUE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_min_size_from_span) + { + static constexpr value_type values[]{value_type{Key('A'), 0}}; + static constexpr etl::span span(values); + static constexpr Data data{ span }; + + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == 1U); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == span.size()); + CHECK_TRUE(max_size == span.size()); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_max_size_from_span) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr span_type span(values); + static constexpr Data data{ span }; + + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == Max_Size); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == Max_Size); + CHECK_TRUE(max_size == Max_Size); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_max_size_from_array) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == Max_Size); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == Max_Size); + CHECK_TRUE(max_size == Max_Size); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_max_size_status_from_iconst_map) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static const constexpr IData& idata = data; + + static constexpr bool is_valid = idata.is_valid(); + static constexpr size_t size = idata.size(); + static constexpr bool empty = idata.empty(); + static constexpr bool full = idata.full(); + static constexpr size_t capacity = idata.capacity(); + static constexpr size_t max_size = idata.max_size(); + static constexpr const_iterator begin = idata.begin(); + static constexpr const_iterator end = idata.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == Max_Size); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == Max_Size); + CHECK_TRUE(max_size == Max_Size); + CHECK_FALSE(begin == end); + } + +#if ETL_USING_CPP17 + //************************************************************************* + TEST(test_cpp17_deduced_constructor_from_span) + { + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr span_type span(values); + static constexpr etl::const_map_ext data{span}; + + etl::const_map check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + CHECK_TRUE(data.is_valid()); + CHECK_TRUE(data.size() == Max_Size); + CHECK_FALSE(data.empty()); + CHECK_TRUE(data.full()); + CHECK_TRUE(data.capacity() == Max_Size); + CHECK_TRUE(data.max_size() == Max_Size); + CHECK_FALSE(data.begin() == data.end()); + } + + //************************************************************************* + TEST(test_cpp17_deduced_constructor_from_array) + { + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr etl::const_map_ext data{values}; + + etl::const_map check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + CHECK_TRUE(data.is_valid()); + CHECK_TRUE(data.size() == Max_Size); + CHECK_FALSE(data.empty()); + CHECK_TRUE(data.full()); + CHECK_TRUE(data.capacity() == Max_Size); + CHECK_TRUE(data.max_size() == Max_Size); + CHECK_FALSE(data.begin() == data.end()); + } +#endif + + //************************************************************************* + TEST(test_begin) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + CHECK_TRUE(data.is_valid()); + static constexpr auto value = *data.begin(); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE((value_type{ Key('J'), 9 }) == value); +#else + CHECK_TRUE((value_type{ Key('A'), 0 }) == value); +#endif + } + + //************************************************************************* + TEST(test_end) + { + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + + static constexpr Data data{ values }; + + static constexpr const_iterator end_itr = data.end(); + + CHECK_TRUE(end_itr == (data.begin() + data.size())); + } + + //************************************************************************* + TEST(test_index) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr mapped_type atA = data[Key('A')]; + static constexpr mapped_type atB = data[Key('B')]; + static constexpr mapped_type atC = data[Key('C')]; + static constexpr mapped_type atD = data[Key('D')]; + static constexpr mapped_type atE = data[Key('E')]; + static constexpr mapped_type atF = data[Key('F')]; + static constexpr mapped_type atG = data[Key('G')]; + static constexpr mapped_type atH = data[Key('H')]; + static constexpr mapped_type atI = data[Key('I')]; + static constexpr mapped_type atJ = data[Key('J')]; + + CHECK_TRUE(data.is_valid()); + CHECK(atA == 0); + CHECK(atB == 1); + CHECK(atC == 2); + CHECK(atD == 3); + CHECK(atE == 4); + CHECK(atF == 5); + CHECK(atG == 6); + CHECK(atH == 7); + CHECK(atI == 8); + CHECK(atJ == 9); + } + + //************************************************************************* + TEST(test_index_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr mapped_type atA = data['A']; + static constexpr mapped_type atB = data['B']; + static constexpr mapped_type atC = data['C']; + static constexpr mapped_type atD = data['D']; + static constexpr mapped_type atE = data['E']; + static constexpr mapped_type atF = data['F']; + static constexpr mapped_type atG = data['G']; + static constexpr mapped_type atH = data['H']; + static constexpr mapped_type atI = data['I']; + static constexpr mapped_type atJ = data['J']; + + CHECK_TRUE(data.is_valid()); + CHECK(atA == 0); + CHECK(atB == 1); + CHECK(atC == 2); + CHECK(atD == 3); + CHECK(atE == 4); + CHECK(atF == 5); + CHECK(atG == 6); + CHECK(atH == 7); + CHECK(atI == 8); + CHECK(atJ == 9); + } + + //************************************************************************* + TEST(test_at) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr mapped_type atA = data.at(Key('A')); + static constexpr mapped_type atB = data.at(Key('B')); + static constexpr mapped_type atC = data.at(Key('C')); + static constexpr mapped_type atD = data.at(Key('D')); + static constexpr mapped_type atE = data.at(Key('E')); + static constexpr mapped_type atF = data.at(Key('F')); + static constexpr mapped_type atG = data.at(Key('G')); + static constexpr mapped_type atH = data.at(Key('H')); + static constexpr mapped_type atI = data.at(Key('I')); + static constexpr mapped_type atJ = data.at(Key('J')); + + CHECK_TRUE(data.is_valid()); + CHECK(atA == 0); + CHECK(atB == 1); + CHECK(atC == 2); + CHECK(atD == 3); + CHECK(atE == 4); + CHECK(atF == 5); + CHECK(atG == 6); + CHECK(atH == 7); + CHECK(atI == 8); + CHECK(atJ == 9); + } + + //************************************************************************* + TEST(test_at_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr mapped_type atA = data.at('A'); + static constexpr mapped_type atB = data.at('B'); + static constexpr mapped_type atC = data.at('C'); + static constexpr mapped_type atD = data.at('D'); + static constexpr mapped_type atE = data.at('E'); + static constexpr mapped_type atF = data.at('F'); + static constexpr mapped_type atG = data.at('G'); + static constexpr mapped_type atH = data.at('H'); + static constexpr mapped_type atI = data.at('I'); + static constexpr mapped_type atJ = data.at('J'); + + CHECK_TRUE(data.is_valid()); + CHECK(atA == 0); + CHECK(atB == 1); + CHECK(atC == 2); + CHECK(atD == 3); + CHECK(atE == 4); + CHECK(atF == 5); + CHECK(atG == 6); + CHECK(atH == 7); + CHECK(atI == 8); + CHECK(atJ == 9); + } + + //************************************************************************* + TEST(test_equal_range) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr ETL_OR_STD::pair resultA = data.equal_range(Key('A')); + static constexpr ETL_OR_STD::pair resultB = data.equal_range(Key('B')); + static constexpr ETL_OR_STD::pair resultC = data.equal_range(Key('C')); + static constexpr ETL_OR_STD::pair resultD = data.equal_range(Key('D')); + static constexpr ETL_OR_STD::pair resultE = data.equal_range(Key('E')); + static constexpr ETL_OR_STD::pair resultF = data.equal_range(Key('F')); + static constexpr ETL_OR_STD::pair resultG = data.equal_range(Key('G')); + static constexpr ETL_OR_STD::pair resultH = data.equal_range(Key('H')); + static constexpr ETL_OR_STD::pair resultI = data.equal_range(Key('I')); + static constexpr ETL_OR_STD::pair resultJ = data.equal_range(Key('J')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(10, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ.second))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(1, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultJ.second))); +#endif + } + + //************************************************************************* + TEST(test_equal_range_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr ETL_OR_STD::pair resultA = data.equal_range('A'); + static constexpr ETL_OR_STD::pair resultB = data.equal_range('B'); + static constexpr ETL_OR_STD::pair resultC = data.equal_range('C'); + static constexpr ETL_OR_STD::pair resultD = data.equal_range('D'); + static constexpr ETL_OR_STD::pair resultE = data.equal_range('E'); + static constexpr ETL_OR_STD::pair resultF = data.equal_range('F'); + static constexpr ETL_OR_STD::pair resultG = data.equal_range('G'); + static constexpr ETL_OR_STD::pair resultH = data.equal_range('H'); + static constexpr ETL_OR_STD::pair resultI = data.equal_range('I'); + static constexpr ETL_OR_STD::pair resultJ = data.equal_range('J'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(10, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ.second))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(1, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultJ.second))); +#endif + } + + //************************************************************************* + TEST(test_lower_bound) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('K'), 10 }, value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, + value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, + value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr const_iterator resultA = data.lower_bound(Key('A')); + static constexpr const_iterator resultB = data.lower_bound(Key('B')); + static constexpr const_iterator resultC = data.lower_bound(Key('C')); + static constexpr const_iterator resultD = data.lower_bound(Key('D')); + static constexpr const_iterator resultE = data.lower_bound(Key('E')); + static constexpr const_iterator resultF = data.lower_bound(Key('F')); + static constexpr const_iterator resultG = data.lower_bound(Key('G')); + static constexpr const_iterator resultH = data.lower_bound(Key('H')); + static constexpr const_iterator resultI = data.lower_bound(Key('I')); + static constexpr const_iterator resultJ = data.lower_bound(Key('J')); + static constexpr const_iterator resultK = data.lower_bound(Key('K')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_lower_bound_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('K'), 10 }, value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, + value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, + value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr const_iterator resultA = data.lower_bound('A'); + static constexpr const_iterator resultB = data.lower_bound('B'); + static constexpr const_iterator resultC = data.lower_bound('C'); + static constexpr const_iterator resultD = data.lower_bound('D'); + static constexpr const_iterator resultE = data.lower_bound('E'); + static constexpr const_iterator resultF = data.lower_bound('F'); + static constexpr const_iterator resultG = data.lower_bound('G'); + static constexpr const_iterator resultH = data.lower_bound('H'); + static constexpr const_iterator resultI = data.lower_bound('I'); + static constexpr const_iterator resultJ = data.lower_bound('J'); + static constexpr const_iterator resultK = data.lower_bound('K'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_upper_bound) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('K'), 10 }, value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, + value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, + value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr const_iterator resultA = data.upper_bound(Key('A')); + static constexpr const_iterator resultB = data.upper_bound(Key('B')); + static constexpr const_iterator resultC = data.upper_bound(Key('C')); + static constexpr const_iterator resultD = data.upper_bound(Key('D')); + static constexpr const_iterator resultE = data.upper_bound(Key('E')); + static constexpr const_iterator resultF = data.upper_bound(Key('F')); + static constexpr const_iterator resultG = data.upper_bound(Key('G')); + static constexpr const_iterator resultH = data.upper_bound(Key('H')); + static constexpr const_iterator resultI = data.upper_bound(Key('I')); + static constexpr const_iterator resultJ = data.upper_bound(Key('J')); + static constexpr const_iterator resultK = data.upper_bound(Key('K')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(1, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_upper_bound_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('K'), 10 }, value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, + value_type{Key('F'), 5 }, value_type{Key('E'), 4 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, + value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 }, value_type{Key('K'), 10 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr const_iterator resultA = data.upper_bound('A'); + static constexpr const_iterator resultB = data.upper_bound('B'); + static constexpr const_iterator resultC = data.upper_bound('C'); + static constexpr const_iterator resultD = data.upper_bound('D'); + static constexpr const_iterator resultE = data.upper_bound('E'); + static constexpr const_iterator resultF = data.upper_bound('F'); + static constexpr const_iterator resultG = data.upper_bound('G'); + static constexpr const_iterator resultH = data.upper_bound('H'); + static constexpr const_iterator resultI = data.upper_bound('I'); + static constexpr const_iterator resultJ = data.upper_bound('J'); + static constexpr const_iterator resultK = data.upper_bound('K'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(1, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_count) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr size_t countA = data.count(Key('A')); + static constexpr size_t countB = data.count(Key('B')); + static constexpr size_t countC = data.count(Key('C')); + static constexpr size_t countD = data.count(Key('D')); + static constexpr size_t countE = data.count(Key('E')); + static constexpr size_t countF = data.count(Key('F')); + static constexpr size_t countG = data.count(Key('G')); + static constexpr size_t countH = data.count(Key('H')); + static constexpr size_t countI = data.count(Key('I')); + static constexpr size_t countJ = data.count(Key('J')); + static constexpr size_t countK = data.count(Key('K')); + + CHECK_EQUAL(1, countA); + CHECK_EQUAL(1, countB); + CHECK_EQUAL(1, countC); + CHECK_EQUAL(1, countD); + CHECK_EQUAL(1, countE); + CHECK_EQUAL(1, countF); + CHECK_EQUAL(1, countG); + CHECK_EQUAL(1, countH); + CHECK_EQUAL(1, countI); + CHECK_EQUAL(1, countJ); + CHECK_EQUAL(0, countK); + } + + //************************************************************************* + TEST(test_count_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr size_t countA = data.count('A'); + static constexpr size_t countB = data.count('B'); + static constexpr size_t countC = data.count('C'); + static constexpr size_t countD = data.count('D'); + static constexpr size_t countE = data.count('E'); + static constexpr size_t countF = data.count('F'); + static constexpr size_t countG = data.count('G'); + static constexpr size_t countH = data.count('H'); + static constexpr size_t countI = data.count('I'); + static constexpr size_t countJ = data.count('J'); + static constexpr size_t countK = data.count('K'); + + CHECK_EQUAL(1, countA); + CHECK_EQUAL(1, countB); + CHECK_EQUAL(1, countC); + CHECK_EQUAL(1, countD); + CHECK_EQUAL(1, countE); + CHECK_EQUAL(1, countF); + CHECK_EQUAL(1, countG); + CHECK_EQUAL(1, countH); + CHECK_EQUAL(1, countI); + CHECK_EQUAL(1, countJ); + CHECK_EQUAL(0, countK); + } + + //************************************************************************* + TEST(test_const_iterator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + const_iterator itr = data.begin(); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE((value_type{Key('J'), 9 }) == *itr++); + CHECK_TRUE((value_type{Key('I'), 8 }) == *itr++); + CHECK_TRUE((value_type{Key('H'), 7 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 6 }) == *itr++); + CHECK_TRUE((value_type{Key('F'), 5 }) == *itr++); + CHECK_TRUE((value_type{Key('E'), 4 }) == *itr++); + CHECK_TRUE((value_type{Key('D'), 3 }) == *itr++); + CHECK_TRUE((value_type{Key('C'), 2 }) == *itr++); + CHECK_TRUE((value_type{Key('B'), 1 }) == *itr++); + CHECK_TRUE((value_type{Key('A'), 0 }) == *itr++); + CHECK_TRUE(itr == data.end()); +#else + CHECK_TRUE((value_type{Key('A'), 0 }) == *itr++); + CHECK_TRUE((value_type{Key('B'), 1 }) == *itr++); + CHECK_TRUE((value_type{Key('C'), 2 }) == *itr++); + CHECK_TRUE((value_type{Key('D'), 3 }) == *itr++); + CHECK_TRUE((value_type{Key('E'), 4 }) == *itr++); + CHECK_TRUE((value_type{Key('F'), 5 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 6 }) == *itr++); + CHECK_TRUE((value_type{Key('H'), 7 }) == *itr++); + CHECK_TRUE((value_type{Key('I'), 8 }) == *itr++); + CHECK_TRUE((value_type{Key('J'), 9 }) == *itr++); + CHECK_TRUE(itr == data.end()); +#endif + } + + //************************************************************************* + TEST(test_find) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr const_iterator resultA = data.find(Key('A')); + static constexpr const_iterator resultB = data.find(Key('B')); + static constexpr const_iterator resultC = data.find(Key('C')); + static constexpr const_iterator resultD = data.find(Key('D')); + static constexpr const_iterator resultE = data.find(Key('E')); + static constexpr const_iterator resultF = data.find(Key('F')); + static constexpr const_iterator resultG = data.find(Key('G')); + static constexpr const_iterator resultH = data.find(Key('H')); + static constexpr const_iterator resultI = data.find(Key('I')); + static constexpr const_iterator resultJ = data.find(Key('J')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); +#endif + } + + //************************************************************************* + TEST(test_find_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr const_iterator resultA = data.find('A'); + static constexpr const_iterator resultB = data.find('B'); + static constexpr const_iterator resultC = data.find('C'); + static constexpr const_iterator resultD = data.find('D'); + static constexpr const_iterator resultE = data.find('E'); + static constexpr const_iterator resultF = data.find('F'); + static constexpr const_iterator resultG = data.find('G'); + static constexpr const_iterator resultH = data.find('H'); + static constexpr const_iterator resultI = data.find('I'); + static constexpr const_iterator resultJ = data.find('J'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); +#endif + } + + //************************************************************************* + TEST(test_key_compare) + { + static constexpr Data data; + + static constexpr Data::key_compare compare = data.key_comp(); + + static constexpr Data::key_type a(Key('A')); + static constexpr Data::key_type b(Key('B')); + +#ifdef TEST_GREATER_THAN + CHECK(!compare(a, b)); + CHECK(compare(b, a)); +#else + CHECK(compare(a, b)); + CHECK(!compare(b, a)); +#endif + } + + //************************************************************************* + TEST(test_key_compare_using_transparent_comparator) + { + static constexpr DataTransparentComparator data; + static constexpr DataTransparentComparator::key_compare compare = data.key_comp(); + + static constexpr DataTransparentComparator::key_type a(Key('A')); + static constexpr DataTransparentComparator::key_type b(Key('B')); + +#ifdef TEST_GREATER_THAN + CHECK(!compare(a, b)); + CHECK(compare(b, a)); +#else + CHECK(compare(a, b)); + CHECK(!compare(b, a)); +#endif + } + + //************************************************************************* + TEST(test_value_compare) + { + static constexpr Data data; + static constexpr Data::value_compare compare = data.value_comp(); + + static constexpr Data::value_type a(Key('A'), 0); + static constexpr Data::value_type b(Key('B'), 1); + +#ifdef TEST_GREATER_THAN + CHECK(!compare(a, b)); + CHECK(compare(b, a)); +#else + CHECK(compare(a, b)); + CHECK(!compare(b, a)); +#endif + } + + //************************************************************************* + TEST(test_contains) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr bool containsA = data.contains(Key('A')); + static constexpr bool containsB = data.contains(Key('B')); + static constexpr bool containsC = data.contains(Key('C')); + static constexpr bool containsD = data.contains(Key('D')); + static constexpr bool containsE = data.contains(Key('E')); + static constexpr bool containsF = data.contains(Key('F')); + static constexpr bool containsG = data.contains(Key('G')); + static constexpr bool containsH = data.contains(Key('H')); + static constexpr bool containsI = data.contains(Key('I')); + static constexpr bool containsJ = data.contains(Key('J')); + static constexpr bool containsK = data.contains(Key('K')); + + CHECK_TRUE(containsA); + CHECK_TRUE(containsB); + CHECK_TRUE(containsC); + CHECK_TRUE(containsD); + CHECK_TRUE(containsE); + CHECK_TRUE(containsF); + CHECK_TRUE(containsG); + CHECK_TRUE(containsH); + CHECK_TRUE(containsI); + CHECK_TRUE(containsJ); + CHECK_FALSE(containsK); + } + + //************************************************************************* + TEST(test_contains_with_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr bool containsA = data.contains('A'); + static constexpr bool containsB = data.contains('B'); + static constexpr bool containsC = data.contains('C'); + static constexpr bool containsD = data.contains('D'); + static constexpr bool containsE = data.contains('E'); + static constexpr bool containsF = data.contains('F'); + static constexpr bool containsG = data.contains('G'); + static constexpr bool containsH = data.contains('H'); + static constexpr bool containsI = data.contains('I'); + static constexpr bool containsJ = data.contains('J'); + static constexpr bool containsK = data.contains('K'); + + CHECK_TRUE(containsA); + CHECK_TRUE(containsB); + CHECK_TRUE(containsC); + CHECK_TRUE(containsD); + CHECK_TRUE(containsE); + CHECK_TRUE(containsF); + CHECK_TRUE(containsG); + CHECK_TRUE(containsH); + CHECK_TRUE(containsI); + CHECK_TRUE(containsJ); + CHECK_FALSE(containsK); + } + + //************************************************************************* + TEST(test_key_comp) + { + static constexpr Data data; + static constexpr Data::key_compare compare = data.key_comp(); + + static constexpr bool compareAA = compare(Key{ 'A' }, Key{ 'A' }); + static constexpr bool compareBA = compare(Key{ 'B' }, Key{ 'A' }); + static constexpr bool compareAB = compare(Key{ 'A' }, Key{ 'B' }); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA); + CHECK_TRUE(compareBA); + CHECK_FALSE(compareAB); +#else + CHECK_FALSE(compareAA); + CHECK_FALSE(compareBA); + CHECK_TRUE(compareAB); +#endif + } + + //************************************************************************* + TEST(test_key_comp_transparent_comparator) + { + static constexpr DataTransparentComparator data; + static constexpr DataTransparentComparator::key_compare compare = data.key_comp(); + + static constexpr bool compareAA = compare('A', 'A'); + static constexpr bool compareBA = compare('B', 'A'); + static constexpr bool compareAB = compare('A', 'B'); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA); + CHECK_TRUE(compareBA); + CHECK_FALSE(compareAB); +#else + CHECK_FALSE(compareAA); + CHECK_FALSE(compareBA); + CHECK_TRUE(compareAB); +#endif + } + + //************************************************************************* + TEST(test_value_comp) + { + static constexpr Data data; + static constexpr Data::value_compare compare = data.value_comp(); + + static constexpr bool compareAA1 = compare(value_type{ Key{ 'A' }, 0 }, value_type{ Key{ 'A' }, 0 }); + static constexpr bool compareAA2 = compare(value_type{ Key{ 'A' }, 0 }, Key{ 'A' }); + static constexpr bool compareAA3 = compare(Key{ 'A' }, value_type{ Key{ 'A' }, 0 }); + + static constexpr bool compareBA1 = compare(value_type{ Key{ 'B' }, 0 }, value_type{ Key{ 'A' }, 0 }); + static constexpr bool compareBA2 = compare(value_type{ Key{ 'B' }, 0 }, Key{ 'A' }); + static constexpr bool compareBA3 = compare(Key{ 'B' }, value_type{ Key{ 'A' }, 0 }); + + static constexpr bool compareAB1 = compare(value_type{ Key{ 'A' }, 0 }, value_type{ Key{ 'B' }, 0 }); + static constexpr bool compareAB2 = compare(value_type{ Key{ 'A' }, 0 }, Key{ 'B' }); + static constexpr bool compareAB3 = compare(Key{ 'A' }, value_type{ Key{ 'B' }, 0 });; + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_TRUE(compareBA1); + CHECK_TRUE(compareBA2); + CHECK_TRUE(compareBA3); + + CHECK_FALSE(compareAB1); + CHECK_FALSE(compareAB2); + CHECK_FALSE(compareAB3); +#else + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_FALSE(compareBA1); + CHECK_FALSE(compareBA2); + CHECK_FALSE(compareBA3); + + CHECK_TRUE(compareAB1); + CHECK_TRUE(compareAB2); + CHECK_TRUE(compareAB3); +#endif + } + + //************************************************************************* + TEST(test_value_comp_transparent_comparator) + { + static constexpr DataTransparentComparator data; + static constexpr DataTransparentComparator::value_compare compare = data.value_comp(); + + static constexpr bool compareAA1 = compare(value_type{ 'A', 0 }, value_type{ 'A', 0 }); + static constexpr bool compareAA2 = compare(value_type{ 'A', 0 }, 'A'); + static constexpr bool compareAA3 = compare('A', value_type{ 'A', 0 }); + + static constexpr bool compareBA1 = compare(value_type{ 'B', 0 }, value_type{ 'A', 0 }); + static constexpr bool compareBA2 = compare(value_type{ 'B', 0 }, 'A'); + static constexpr bool compareBA3 = compare('B', value_type{ 'A', 0 }); + + static constexpr bool compareAB1 = compare(value_type{ 'A', 0 }, value_type{ 'B', 0 }); + static constexpr bool compareAB2 = compare(value_type{ 'A', 0 }, 'B'); + static constexpr bool compareAB3 = compare('A', value_type{ 'B', 0 });; + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_TRUE(compareBA1); + CHECK_TRUE(compareBA2); + CHECK_TRUE(compareBA3); + + CHECK_FALSE(compareAB1); + CHECK_FALSE(compareAB2); + CHECK_FALSE(compareAB3); +#else + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_FALSE(compareBA1); + CHECK_FALSE(compareBA2); + CHECK_FALSE(compareBA3); + + CHECK_TRUE(compareAB1); + CHECK_TRUE(compareAB2); + CHECK_TRUE(compareAB3); +#endif + } + + //************************************************************************* + TEST(test_equal) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data1{values1}; + static constexpr Data data2{values2}; + static constexpr Data data3{values3}; + + static constexpr bool equal12 = (data1 == data2); + static constexpr bool equal13 = (data1 == data3); + + CHECK_TRUE(equal12); + CHECK_FALSE(equal13); + } + + //************************************************************************* + TEST(test_equal_with_transparent_comparator) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr DataTransparentComparator data1{values1}; + static constexpr DataTransparentComparator data2{values2}; + static constexpr DataTransparentComparator data3{values3}; + + static constexpr bool equal12 = (data1 == data2); + static constexpr bool equal13 = (data1 == data3); + + CHECK_TRUE(equal12); + CHECK_FALSE(equal13); + } + + //************************************************************************* + TEST(test_not_equal) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data1{values1}; + static constexpr Data data2{values2}; + static constexpr Data data3{values3}; + + static constexpr bool not_equal12 = (data1 != data2); + static constexpr bool not_equal13 = (data1 != data3); + + CHECK_FALSE(not_equal12); + CHECK_TRUE(not_equal13); + } + + //************************************************************************* + TEST(test_not_equal_with_transparent_comparator) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr DataTransparentComparator data1{values1}; + static constexpr DataTransparentComparator data2{values2}; + static constexpr DataTransparentComparator data3{values3}; + + static constexpr bool not_equal12 = (data1 != data2); + static constexpr bool not_equal13 = (data1 != data3); + + CHECK_FALSE(not_equal12); + CHECK_TRUE(not_equal13); + } + + //************************************************************************* + TEST(test_less_than) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data1{values1}; + static constexpr Data data2{values2}; + static constexpr Data data3{values3}; + + static constexpr bool less_than12 = (data1 < data2); + static constexpr bool less_than23 = (data2 < data3); + static constexpr bool less_than21 = (data2 < data1); + static constexpr bool less_than32 = (data3 < data2); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than12); + CHECK_FALSE(less_than23); + CHECK_TRUE(less_than21); + CHECK_TRUE(less_than32); +#else + CHECK_TRUE(less_than12); + CHECK_TRUE(less_than23); + CHECK_FALSE(less_than21); + CHECK_FALSE(less_than32); +#endif + } + + //************************************************************************* + TEST(test_less_than_with_transparent_comparator) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr DataTransparentComparator data1{values1}; + static constexpr DataTransparentComparator data2{values2}; + static constexpr DataTransparentComparator data3{values3}; + + static constexpr bool less_than12 = (data1 < data2); + static constexpr bool less_than23 = (data2 < data3); + static constexpr bool less_than21 = (data2 < data1); + static constexpr bool less_than32 = (data3 < data2); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than12); + CHECK_FALSE(less_than23); + CHECK_TRUE(less_than21); + CHECK_TRUE(less_than32); +#else + CHECK_TRUE(less_than12); + CHECK_TRUE(less_than23); + CHECK_FALSE(less_than21); + CHECK_FALSE(less_than32); +#endif + } + + //************************************************************************* + TEST(test_less_than_equal) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data1{values1}; + static constexpr Data data2{values2}; + static constexpr Data data3{values3}; + + static constexpr bool less_than_equal12 = (data1 <= data2); + static constexpr bool less_than_equal23 = (data2 <= data3); + static constexpr bool less_than_equal21 = (data2 <= data1); + static constexpr bool less_than_equal32 = (data3 <= data2); + static constexpr bool less_than_equal11 = (data1 <= data1); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than_equal12); + CHECK_FALSE(less_than_equal23); + CHECK_TRUE(less_than_equal21); + CHECK_TRUE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#else + CHECK_TRUE(less_than_equal12); + CHECK_TRUE(less_than_equal23); + CHECK_FALSE(less_than_equal21); + CHECK_FALSE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#endif + } + + //************************************************************************* + TEST(test_less_than_equal_with_transparent_comparator) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr DataTransparentComparator data1{values1}; + static constexpr DataTransparentComparator data2{values2}; + static constexpr DataTransparentComparator data3{values3}; + + static constexpr bool less_than_equal12 = (data1 <= data2); + static constexpr bool less_than_equal23 = (data2 <= data3); + static constexpr bool less_than_equal21 = (data2 <= data1); + static constexpr bool less_than_equal32 = (data3 <= data2); + static constexpr bool less_than_equal11 = (data1 <= data1); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than_equal12); + CHECK_FALSE(less_than_equal23); + CHECK_TRUE(less_than_equal21); + CHECK_TRUE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#else + CHECK_TRUE(less_than_equal12); + CHECK_TRUE(less_than_equal23); + CHECK_FALSE(less_than_equal21); + CHECK_FALSE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#endif + } + + //************************************************************************* + TEST(test_greater_than) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data1{values1}; + static constexpr Data data2{values2}; + static constexpr Data data3{values3}; + + static constexpr bool greater_than12 = (data1 > data2); + static constexpr bool greater_than23 = (data2 > data3); + static constexpr bool greater_than21 = (data2 > data1); + static constexpr bool greater_than32 = (data3 > data2); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than12); + CHECK_TRUE(greater_than23); + CHECK_FALSE(greater_than21); + CHECK_FALSE(greater_than32); +#else + CHECK_FALSE(greater_than12); + CHECK_FALSE(greater_than23); + CHECK_TRUE(greater_than21); + CHECK_TRUE(greater_than32); +#endif + } + + //************************************************************************* + TEST(test_greater_than_with_transparent_comparator) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr DataTransparentComparator data1{values1}; + static constexpr DataTransparentComparator data2{values2}; + static constexpr DataTransparentComparator data3{values3}; + + static constexpr bool greater_than12 = (data1 > data2); + static constexpr bool greater_than23 = (data2 > data3); + static constexpr bool greater_than21 = (data2 > data1); + static constexpr bool greater_than32 = (data3 > data2); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than12); + CHECK_TRUE(greater_than23); + CHECK_FALSE(greater_than21); + CHECK_FALSE(greater_than32); +#else + CHECK_FALSE(greater_than12); + CHECK_FALSE(greater_than23); + CHECK_TRUE(greater_than21); + CHECK_TRUE(greater_than32); +#endif + } + + //************************************************************************* + TEST(test_greater_than_equal) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data1{values1}; + static constexpr Data data2{values2}; + static constexpr Data data3{values3}; + + static constexpr bool greater_than_equal12 = (data1 >= data2); + static constexpr bool greater_than_equal23 = (data2 >= data3); + static constexpr bool greater_than_equal21 = (data2 >= data1); + static constexpr bool greater_than_equal32 = (data3 >= data2); + static constexpr bool greater_than_equal11 = (data1 >= data1); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than_equal12); + CHECK_TRUE(greater_than_equal23); + CHECK_FALSE(greater_than_equal21); + CHECK_FALSE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#else + CHECK_FALSE(greater_than_equal12); + CHECK_FALSE(greater_than_equal23); + CHECK_TRUE(greater_than_equal21); + CHECK_TRUE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#endif + } + + //************************************************************************* + TEST(test_greater_than_equal_with_transparent_comparator) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr DataTransparentComparator data1{values1}; + static constexpr DataTransparentComparator data2{values2}; + static constexpr DataTransparentComparator data3{values3}; + + static constexpr bool greater_than_equal12 = (data1 >= data2); + static constexpr bool greater_than_equal23 = (data2 >= data3); + static constexpr bool greater_than_equal21 = (data2 >= data1); + static constexpr bool greater_than_equal32 = (data3 >= data2); + static constexpr bool greater_than_equal11 = (data1 >= data1); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than_equal12); + CHECK_TRUE(greater_than_equal23); + CHECK_FALSE(greater_than_equal21); + CHECK_FALSE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#else + CHECK_FALSE(greater_than_equal12); + CHECK_FALSE(greater_than_equal23); + CHECK_TRUE(greater_than_equal21); + CHECK_TRUE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#endif + } + }; +} diff --git a/test/test_const_multimap.cpp b/test/test_const_multimap.cpp index d3c8bd7b..de9a1089 100644 --- a/test/test_const_multimap.cpp +++ b/test/test_const_multimap.cpp @@ -102,8 +102,10 @@ namespace using IDataTransparentComparator = etl::iconst_multimap>; #endif - using value_type = Data::value_type; - using Data_const_iterator = Data::const_iterator; + using value_type = Data::value_type; + using key_type = Data::key_type; + using mapped_type = Data::mapped_type; + using const_iterator = Data::const_iterator; SUITE(test_const_multimap) { @@ -112,14 +114,14 @@ namespace { static const Data data; - static const bool is_valid = data.is_valid(); - static const size_t size = data.size(); - static const bool empty = data.empty(); - static const bool full = data.full(); - static const size_t capacity = data.capacity(); - static const size_t max_size = data.max_size(); - static const Data::const_iterator begin = data.begin(); - static const Data::const_iterator end = data.end(); + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == 0UL); @@ -135,14 +137,14 @@ namespace { static const Data data{ value_type{Key('A'), 0 } }; - static const bool is_valid = data.is_valid(); - static const size_t size = data.size(); - static const bool empty = data.empty(); - static const bool full = data.full(); - static const size_t capacity = data.capacity(); - static const size_t max_size = data.max_size(); - static const Data::const_iterator begin = data.begin(); - static const Data::const_iterator end = data.end(); + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == 1U); @@ -158,20 +160,20 @@ namespace { #ifdef TEST_GREATER_THAN static const Data data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static const bool is_valid = data.is_valid(); - static const size_t size = data.size(); - static const bool empty = data.empty(); - static const bool full = data.full(); - static const size_t capacity = data.capacity(); - static const size_t max_size = data.max_size(); - static const Data::const_iterator begin = data.begin(); - static const Data::const_iterator end = data.end(); + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == Max_Size); @@ -196,21 +198,12 @@ namespace //************************************************************************* TEST(test_cpp17_deduced_constructor) { -#ifdef TEST_GREATER_THAN - static const Data data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; -#else - static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; -#endif + static const etl::const_multimap data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; -#ifdef TEST_GREATER_THAN - etl::const_multimap check{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; -#else etl::const_multimap check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; -#endif + CHECK_TRUE(data.is_valid()); CHECK_TRUE(data.size() == Max_Size); CHECK_FALSE(data.empty()); @@ -248,7 +241,7 @@ namespace static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; - static const Data::const_iterator end_itr = data.end(); + static const const_iterator end_itr = data.end(); CHECK_TRUE(end_itr == (data.begin() + data.size())); } @@ -264,16 +257,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static const ETL_OR_STD::pair resultA = data.equal_range(Key('A')); - static const ETL_OR_STD::pair resultB = data.equal_range(Key('B')); - static const ETL_OR_STD::pair resultC = data.equal_range(Key('C')); - static const ETL_OR_STD::pair resultD = data.equal_range(Key('D')); - static const ETL_OR_STD::pair resultE = data.equal_range(Key('E')); - static const ETL_OR_STD::pair resultF = data.equal_range(Key('F')); - static const ETL_OR_STD::pair resultG = data.equal_range(Key('G')); - static const ETL_OR_STD::pair resultH = data.equal_range(Key('H')); - static const ETL_OR_STD::pair resultI = data.equal_range(Key('I')); - static const ETL_OR_STD::pair resultJ = data.equal_range(Key('J')); + static const ETL_OR_STD::pair resultA = data.equal_range(Key('A')); + static const ETL_OR_STD::pair resultB = data.equal_range(Key('B')); + static const ETL_OR_STD::pair resultC = data.equal_range(Key('C')); + static const ETL_OR_STD::pair resultD = data.equal_range(Key('D')); + static const ETL_OR_STD::pair resultE = data.equal_range(Key('E')); + static const ETL_OR_STD::pair resultF = data.equal_range(Key('F')); + static const ETL_OR_STD::pair resultG = data.equal_range(Key('G')); + static const ETL_OR_STD::pair resultH = data.equal_range(Key('H')); + static const ETL_OR_STD::pair resultI = data.equal_range(Key('I')); + static const ETL_OR_STD::pair resultJ = data.equal_range(Key('J')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); @@ -333,16 +326,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static const ETL_OR_STD::pair resultA = data.equal_range('A'); - static const ETL_OR_STD::pair resultB = data.equal_range('B'); - static const ETL_OR_STD::pair resultC = data.equal_range('C'); - static const ETL_OR_STD::pair resultD = data.equal_range('D'); - static const ETL_OR_STD::pair resultE = data.equal_range('E'); - static const ETL_OR_STD::pair resultF = data.equal_range('F'); - static const ETL_OR_STD::pair resultG = data.equal_range('G'); - static const ETL_OR_STD::pair resultH = data.equal_range('H'); - static const ETL_OR_STD::pair resultI = data.equal_range('I'); - static const ETL_OR_STD::pair resultJ = data.equal_range('J'); + static const ETL_OR_STD::pair resultA = data.equal_range('A'); + static const ETL_OR_STD::pair resultB = data.equal_range('B'); + static const ETL_OR_STD::pair resultC = data.equal_range('C'); + static const ETL_OR_STD::pair resultD = data.equal_range('D'); + static const ETL_OR_STD::pair resultE = data.equal_range('E'); + static const ETL_OR_STD::pair resultF = data.equal_range('F'); + static const ETL_OR_STD::pair resultG = data.equal_range('G'); + static const ETL_OR_STD::pair resultH = data.equal_range('H'); + static const ETL_OR_STD::pair resultI = data.equal_range('I'); + static const ETL_OR_STD::pair resultJ = data.equal_range('J'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); @@ -395,24 +388,24 @@ namespace TEST(test_lower_bound_const) { #ifdef TEST_GREATER_THAN - static const DataTransparentComparator data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + static const Data data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else - static const DataTransparentComparator data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static const Data::const_iterator resultA = data.lower_bound(Key('A')); - static const Data::const_iterator resultB = data.lower_bound(Key('B')); - static const Data::const_iterator resultC = data.lower_bound(Key('C')); - static const Data::const_iterator resultD = data.lower_bound(Key('D')); - static const Data::const_iterator resultE = data.lower_bound(Key('E')); - static const Data::const_iterator resultF = data.lower_bound(Key('F')); - static const Data::const_iterator resultG = data.lower_bound(Key('G')); - static const Data::const_iterator resultH = data.lower_bound(Key('H')); - static const Data::const_iterator resultI = data.lower_bound(Key('I')); - static const Data::const_iterator resultJ = data.lower_bound(Key('J')); - static const Data::const_iterator resultK = data.lower_bound(Key('K')); + static const const_iterator resultA = data.lower_bound(Key('A')); + static const const_iterator resultB = data.lower_bound(Key('B')); + static const const_iterator resultC = data.lower_bound(Key('C')); + static const const_iterator resultD = data.lower_bound(Key('D')); + static const const_iterator resultE = data.lower_bound(Key('E')); + static const const_iterator resultF = data.lower_bound(Key('F')); + static const const_iterator resultG = data.lower_bound(Key('G')); + static const const_iterator resultH = data.lower_bound(Key('H')); + static const const_iterator resultI = data.lower_bound(Key('I')); + static const const_iterator resultJ = data.lower_bound(Key('J')); + static const const_iterator resultK = data.lower_bound(Key('K')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -452,17 +445,17 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static const Data::const_iterator resultA = data.lower_bound('A'); - static const Data::const_iterator resultB = data.lower_bound('B'); - static const Data::const_iterator resultC = data.lower_bound('C'); - static const Data::const_iterator resultD = data.lower_bound('D'); - static const Data::const_iterator resultE = data.lower_bound('E'); - static const Data::const_iterator resultF = data.lower_bound('F'); - static const Data::const_iterator resultG = data.lower_bound('G'); - static const Data::const_iterator resultH = data.lower_bound('H'); - static const Data::const_iterator resultI = data.lower_bound('I'); - static const Data::const_iterator resultJ = data.lower_bound('J'); - static const Data::const_iterator resultK = data.lower_bound('K'); + static const const_iterator resultA = data.lower_bound('A'); + static const const_iterator resultB = data.lower_bound('B'); + static const const_iterator resultC = data.lower_bound('C'); + static const const_iterator resultD = data.lower_bound('D'); + static const const_iterator resultE = data.lower_bound('E'); + static const const_iterator resultF = data.lower_bound('F'); + static const const_iterator resultG = data.lower_bound('G'); + static const const_iterator resultH = data.lower_bound('H'); + static const const_iterator resultI = data.lower_bound('I'); + static const const_iterator resultJ = data.lower_bound('J'); + static const const_iterator resultK = data.lower_bound('K'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -495,24 +488,24 @@ namespace TEST(test_upper_bound_const) { #ifdef TEST_GREATER_THAN - static const DataTransparentComparator data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + static const Data data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else - static const DataTransparentComparator data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static const Data::const_iterator resultA = data.upper_bound(Key('A')); - static const Data::const_iterator resultB = data.upper_bound(Key('B')); - static const Data::const_iterator resultC = data.upper_bound(Key('C')); - static const Data::const_iterator resultD = data.upper_bound(Key('D')); - static const Data::const_iterator resultE = data.upper_bound(Key('E')); - static const Data::const_iterator resultF = data.upper_bound(Key('F')); - static const Data::const_iterator resultG = data.upper_bound(Key('G')); - static const Data::const_iterator resultH = data.upper_bound(Key('H')); - static const Data::const_iterator resultI = data.upper_bound(Key('I')); - static const Data::const_iterator resultJ = data.upper_bound(Key('J')); - static const Data::const_iterator resultK = data.upper_bound(Key('K')); + static const const_iterator resultA = data.upper_bound(Key('A')); + static const const_iterator resultB = data.upper_bound(Key('B')); + static const const_iterator resultC = data.upper_bound(Key('C')); + static const const_iterator resultD = data.upper_bound(Key('D')); + static const const_iterator resultE = data.upper_bound(Key('E')); + static const const_iterator resultF = data.upper_bound(Key('F')); + static const const_iterator resultG = data.upper_bound(Key('G')); + static const const_iterator resultH = data.upper_bound(Key('H')); + static const const_iterator resultI = data.upper_bound(Key('I')); + static const const_iterator resultJ = data.upper_bound(Key('J')); + static const const_iterator resultK = data.upper_bound(Key('K')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); @@ -552,17 +545,17 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static const Data::const_iterator resultA = data.upper_bound('A'); - static const Data::const_iterator resultB = data.upper_bound('B'); - static const Data::const_iterator resultC = data.upper_bound('C'); - static const Data::const_iterator resultD = data.upper_bound('D'); - static const Data::const_iterator resultE = data.upper_bound('E'); - static const Data::const_iterator resultF = data.upper_bound('F'); - static const Data::const_iterator resultG = data.upper_bound('G'); - static const Data::const_iterator resultH = data.upper_bound('H'); - static const Data::const_iterator resultI = data.upper_bound('I'); - static const Data::const_iterator resultJ = data.upper_bound('J'); - static const Data::const_iterator resultK = data.upper_bound('K'); + static const const_iterator resultA = data.upper_bound('A'); + static const const_iterator resultB = data.upper_bound('B'); + static const const_iterator resultC = data.upper_bound('C'); + static const const_iterator resultD = data.upper_bound('D'); + static const const_iterator resultE = data.upper_bound('E'); + static const const_iterator resultF = data.upper_bound('F'); + static const const_iterator resultG = data.upper_bound('G'); + static const const_iterator resultH = data.upper_bound('H'); + static const const_iterator resultI = data.upper_bound('I'); + static const const_iterator resultJ = data.upper_bound('J'); + static const const_iterator resultK = data.upper_bound('K'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); @@ -595,11 +588,11 @@ namespace TEST(test_count_const) { #ifdef TEST_GREATER_THAN - static const DataTransparentComparator data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + static const Data data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else - static const DataTransparentComparator data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif CHECK_EQUAL(1, data.count(Key('A'))); @@ -643,14 +636,14 @@ namespace TEST(test_const_iterator) { #ifdef TEST_GREATER_THAN - static const DataTransparentComparator data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + static const Data data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else - static const DataTransparentComparator data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - Data::const_iterator itr = data.begin(); + const_iterator itr = data.begin(); #ifdef TEST_GREATER_THAN CHECK_TRUE((value_type{Key('J'), 9 }) == *itr++); @@ -683,23 +676,23 @@ namespace TEST(test_find_const) { #ifdef TEST_GREATER_THAN - static const DataTransparentComparator data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + static const Data data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else - static const DataTransparentComparator data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static const Data::const_iterator resultA = data.find(Key('A')); - static const Data::const_iterator resultB = data.find(Key('B')); - static const Data::const_iterator resultC = data.find(Key('C')); - static const Data::const_iterator resultD = data.find(Key('D')); - static const Data::const_iterator resultE = data.find(Key('E')); - static const Data::const_iterator resultF = data.find(Key('F')); - static const Data::const_iterator resultG = data.find(Key('G')); - static const Data::const_iterator resultH = data.find(Key('H')); - static const Data::const_iterator resultI = data.find(Key('I')); - static const Data::const_iterator resultJ = data.find(Key('J')); + static const const_iterator resultA = data.find(Key('A')); + static const const_iterator resultB = data.find(Key('B')); + static const const_iterator resultC = data.find(Key('C')); + static const const_iterator resultD = data.find(Key('D')); + static const const_iterator resultE = data.find(Key('E')); + static const const_iterator resultF = data.find(Key('F')); + static const const_iterator resultG = data.find(Key('G')); + static const const_iterator resultH = data.find(Key('H')); + static const const_iterator resultI = data.find(Key('I')); + static const const_iterator resultJ = data.find(Key('J')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -737,16 +730,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static const Data::const_iterator resultA = data.find('A'); - static const Data::const_iterator resultB = data.find('B'); - static const Data::const_iterator resultC = data.find('C'); - static const Data::const_iterator resultD = data.find('D'); - static const Data::const_iterator resultE = data.find('E'); - static const Data::const_iterator resultF = data.find('F'); - static const Data::const_iterator resultG = data.find('G'); - static const Data::const_iterator resultH = data.find('H'); - static const Data::const_iterator resultI = data.find('I'); - static const Data::const_iterator resultJ = data.find('J'); + static const const_iterator resultA = data.find('A'); + static const const_iterator resultB = data.find('B'); + static const const_iterator resultC = data.find('C'); + static const const_iterator resultD = data.find('D'); + static const const_iterator resultE = data.find('E'); + static const const_iterator resultF = data.find('F'); + static const const_iterator resultG = data.find('G'); + static const const_iterator resultH = data.find('H'); + static const const_iterator resultI = data.find('I'); + static const const_iterator resultJ = data.find('J'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -777,11 +770,11 @@ namespace TEST(test_contains_const) { #ifdef TEST_GREATER_THAN - static const DataTransparentComparator data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; + static const Data data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; #else - static const DataTransparentComparator data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + static const Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif static const bool containsA = data.contains(Key('A')); diff --git a/test/test_const_multimap_constexpr.cpp b/test/test_const_multimap_constexpr.cpp index dd7d4036..68720992 100644 --- a/test/test_const_multimap_constexpr.cpp +++ b/test/test_const_multimap_constexpr.cpp @@ -104,8 +104,10 @@ namespace using IDataTransparentComparator = etl::iconst_multimap>; #endif - using value_type = Data::value_type; - using Data_const_iterator = Data::const_iterator; + using value_type = Data::value_type; + using key_type = Data::key_type; + using mapped_type = Data::mapped_type; + using const_iterator = Data::const_iterator; SUITE(test_const_multimap) { @@ -114,14 +116,14 @@ namespace { static constexpr Data data; - static constexpr bool is_valid = data.is_valid(); - static constexpr size_t size = data.size(); - static constexpr bool empty = data.empty(); - static constexpr bool full = data.full(); - static constexpr size_t capacity = data.capacity(); - static constexpr size_t max_size = data.max_size(); - static constexpr Data::const_iterator begin = data.begin(); - static constexpr Data::const_iterator end = data.end(); + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == 0UL); @@ -137,14 +139,14 @@ namespace { static constexpr Data data{ value_type{Key('A'), 0 } }; - static constexpr bool is_valid = data.is_valid(); - static constexpr size_t size = data.size(); - static constexpr bool empty = data.empty(); - static constexpr bool full = data.full(); - static constexpr size_t capacity = data.capacity(); - static constexpr size_t max_size = data.max_size(); - static constexpr Data::const_iterator begin = data.begin(); - static constexpr Data::const_iterator end = data.end(); + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == 1U); @@ -166,14 +168,14 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr bool is_valid = data.is_valid(); - static constexpr size_t size = data.size(); - static constexpr bool empty = data.empty(); - static constexpr bool full = data.full(); - static constexpr size_t capacity = data.capacity(); - static constexpr size_t max_size = data.max_size(); - static constexpr Data::const_iterator begin = data.begin(); - static constexpr Data::const_iterator end = data.end(); + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); CHECK_TRUE(is_valid); CHECK_TRUE(size == Max_Size); @@ -198,21 +200,12 @@ namespace //************************************************************************* TEST(test_cpp17_deduced_constructor) { -#ifdef TEST_GREATER_THAN - static constexpr Data data{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; -#else - static constexpr Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, - value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; -#endif + static constexpr etl::const_multimap data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; -#ifdef TEST_GREATER_THAN - etl::const_multimap check{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, - value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; -#else etl::const_multimap check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; -#endif + CHECK_TRUE(data.is_valid()); CHECK_TRUE(data.size() == Max_Size); CHECK_FALSE(data.empty()); @@ -250,7 +243,7 @@ namespace static constexpr Data data{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; - static constexpr Data::const_iterator end_itr = data.end(); + static constexpr const_iterator end_itr = data.end(); CHECK_TRUE(end_itr == (data.begin() + data.size())); } @@ -266,16 +259,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr ETL_OR_STD::pair resultA = data.equal_range(Key('A')); - static constexpr ETL_OR_STD::pair resultB = data.equal_range(Key('B')); - static constexpr ETL_OR_STD::pair resultC = data.equal_range(Key('C')); - static constexpr ETL_OR_STD::pair resultD = data.equal_range(Key('D')); - static constexpr ETL_OR_STD::pair resultE = data.equal_range(Key('E')); - static constexpr ETL_OR_STD::pair resultF = data.equal_range(Key('F')); - static constexpr ETL_OR_STD::pair resultG = data.equal_range(Key('G')); - static constexpr ETL_OR_STD::pair resultH = data.equal_range(Key('H')); - static constexpr ETL_OR_STD::pair resultI = data.equal_range(Key('I')); - static constexpr ETL_OR_STD::pair resultJ = data.equal_range(Key('J')); + static constexpr ETL_OR_STD::pair resultA = data.equal_range(Key('A')); + static constexpr ETL_OR_STD::pair resultB = data.equal_range(Key('B')); + static constexpr ETL_OR_STD::pair resultC = data.equal_range(Key('C')); + static constexpr ETL_OR_STD::pair resultD = data.equal_range(Key('D')); + static constexpr ETL_OR_STD::pair resultE = data.equal_range(Key('E')); + static constexpr ETL_OR_STD::pair resultF = data.equal_range(Key('F')); + static constexpr ETL_OR_STD::pair resultG = data.equal_range(Key('G')); + static constexpr ETL_OR_STD::pair resultH = data.equal_range(Key('H')); + static constexpr ETL_OR_STD::pair resultI = data.equal_range(Key('I')); + static constexpr ETL_OR_STD::pair resultJ = data.equal_range(Key('J')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); @@ -335,17 +328,17 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr Data::const_iterator resultA = data.lower_bound(Key('A')); - static constexpr Data::const_iterator resultB = data.lower_bound(Key('B')); - static constexpr Data::const_iterator resultC = data.lower_bound(Key('C')); - static constexpr Data::const_iterator resultD = data.lower_bound(Key('D')); - static constexpr Data::const_iterator resultE = data.lower_bound(Key('E')); - static constexpr Data::const_iterator resultF = data.lower_bound(Key('F')); - static constexpr Data::const_iterator resultG = data.lower_bound(Key('G')); - static constexpr Data::const_iterator resultH = data.lower_bound(Key('H')); - static constexpr Data::const_iterator resultI = data.lower_bound(Key('I')); - static constexpr Data::const_iterator resultJ = data.lower_bound(Key('J')); - static constexpr Data::const_iterator resultK = data.lower_bound(Key('K')); + static constexpr const_iterator resultA = data.lower_bound(Key('A')); + static constexpr const_iterator resultB = data.lower_bound(Key('B')); + static constexpr const_iterator resultC = data.lower_bound(Key('C')); + static constexpr const_iterator resultD = data.lower_bound(Key('D')); + static constexpr const_iterator resultE = data.lower_bound(Key('E')); + static constexpr const_iterator resultF = data.lower_bound(Key('F')); + static constexpr const_iterator resultG = data.lower_bound(Key('G')); + static constexpr const_iterator resultH = data.lower_bound(Key('H')); + static constexpr const_iterator resultI = data.lower_bound(Key('I')); + static constexpr const_iterator resultJ = data.lower_bound(Key('J')); + static constexpr const_iterator resultK = data.lower_bound(Key('K')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -385,17 +378,17 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr Data::const_iterator resultA = data.lower_bound('A'); - static constexpr Data::const_iterator resultB = data.lower_bound('B'); - static constexpr Data::const_iterator resultC = data.lower_bound('C'); - static constexpr Data::const_iterator resultD = data.lower_bound('D'); - static constexpr Data::const_iterator resultE = data.lower_bound('E'); - static constexpr Data::const_iterator resultF = data.lower_bound('F'); - static constexpr Data::const_iterator resultG = data.lower_bound('G'); - static constexpr Data::const_iterator resultH = data.lower_bound('H'); - static constexpr Data::const_iterator resultI = data.lower_bound('I'); - static constexpr Data::const_iterator resultJ = data.lower_bound('J'); - static constexpr Data::const_iterator resultK = data.lower_bound('K'); + static constexpr const_iterator resultA = data.lower_bound('A'); + static constexpr const_iterator resultB = data.lower_bound('B'); + static constexpr const_iterator resultC = data.lower_bound('C'); + static constexpr const_iterator resultD = data.lower_bound('D'); + static constexpr const_iterator resultE = data.lower_bound('E'); + static constexpr const_iterator resultF = data.lower_bound('F'); + static constexpr const_iterator resultG = data.lower_bound('G'); + static constexpr const_iterator resultH = data.lower_bound('H'); + static constexpr const_iterator resultI = data.lower_bound('I'); + static constexpr const_iterator resultJ = data.lower_bound('J'); + static constexpr const_iterator resultK = data.lower_bound('K'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -435,17 +428,17 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr Data::const_iterator resultA = data.upper_bound(Key('A')); - static constexpr Data::const_iterator resultB = data.upper_bound(Key('B')); - static constexpr Data::const_iterator resultC = data.upper_bound(Key('C')); - static constexpr Data::const_iterator resultD = data.upper_bound(Key('D')); - static constexpr Data::const_iterator resultE = data.upper_bound(Key('E')); - static constexpr Data::const_iterator resultF = data.upper_bound(Key('F')); - static constexpr Data::const_iterator resultG = data.upper_bound(Key('G')); - static constexpr Data::const_iterator resultH = data.upper_bound(Key('H')); - static constexpr Data::const_iterator resultI = data.upper_bound(Key('I')); - static constexpr Data::const_iterator resultJ = data.upper_bound(Key('J')); - static constexpr Data::const_iterator resultK = data.upper_bound(Key('K')); + static constexpr const_iterator resultA = data.upper_bound(Key('A')); + static constexpr const_iterator resultB = data.upper_bound(Key('B')); + static constexpr const_iterator resultC = data.upper_bound(Key('C')); + static constexpr const_iterator resultD = data.upper_bound(Key('D')); + static constexpr const_iterator resultE = data.upper_bound(Key('E')); + static constexpr const_iterator resultF = data.upper_bound(Key('F')); + static constexpr const_iterator resultG = data.upper_bound(Key('G')); + static constexpr const_iterator resultH = data.upper_bound(Key('H')); + static constexpr const_iterator resultI = data.upper_bound(Key('I')); + static constexpr const_iterator resultJ = data.upper_bound(Key('J')); + static constexpr const_iterator resultK = data.upper_bound(Key('K')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); @@ -485,17 +478,17 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr Data::const_iterator resultA = data.upper_bound('A'); - static constexpr Data::const_iterator resultB = data.upper_bound('B'); - static constexpr Data::const_iterator resultC = data.upper_bound('C'); - static constexpr Data::const_iterator resultD = data.upper_bound('D'); - static constexpr Data::const_iterator resultE = data.upper_bound('E'); - static constexpr Data::const_iterator resultF = data.upper_bound('F'); - static constexpr Data::const_iterator resultG = data.upper_bound('G'); - static constexpr Data::const_iterator resultH = data.upper_bound('H'); - static constexpr Data::const_iterator resultI = data.upper_bound('I'); - static constexpr Data::const_iterator resultJ = data.upper_bound('J'); - static constexpr Data::const_iterator resultK = data.upper_bound('K'); + static constexpr const_iterator resultA = data.upper_bound('A'); + static constexpr const_iterator resultB = data.upper_bound('B'); + static constexpr const_iterator resultC = data.upper_bound('C'); + static constexpr const_iterator resultD = data.upper_bound('D'); + static constexpr const_iterator resultE = data.upper_bound('E'); + static constexpr const_iterator resultF = data.upper_bound('F'); + static constexpr const_iterator resultG = data.upper_bound('G'); + static constexpr const_iterator resultH = data.upper_bound('H'); + static constexpr const_iterator resultI = data.upper_bound('I'); + static constexpr const_iterator resultJ = data.upper_bound('J'); + static constexpr const_iterator resultK = data.upper_bound('K'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); @@ -583,7 +576,7 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - Data::const_iterator itr = data.begin(); + const_iterator itr = data.begin(); #ifdef TEST_GREATER_THAN CHECK_TRUE((value_type{Key('J'), 9 }) == *itr++); @@ -623,16 +616,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr Data::const_iterator resultA = data.find(Key('A')); - static constexpr Data::const_iterator resultB = data.find(Key('B')); - static constexpr Data::const_iterator resultC = data.find(Key('C')); - static constexpr Data::const_iterator resultD = data.find(Key('D')); - static constexpr Data::const_iterator resultE = data.find(Key('E')); - static constexpr Data::const_iterator resultF = data.find(Key('F')); - static constexpr Data::const_iterator resultG = data.find(Key('G')); - static constexpr Data::const_iterator resultH = data.find(Key('H')); - static constexpr Data::const_iterator resultI = data.find(Key('I')); - static constexpr Data::const_iterator resultJ = data.find(Key('J')); + static constexpr const_iterator resultA = data.find(Key('A')); + static constexpr const_iterator resultB = data.find(Key('B')); + static constexpr const_iterator resultC = data.find(Key('C')); + static constexpr const_iterator resultD = data.find(Key('D')); + static constexpr const_iterator resultE = data.find(Key('E')); + static constexpr const_iterator resultF = data.find(Key('F')); + static constexpr const_iterator resultG = data.find(Key('G')); + static constexpr const_iterator resultH = data.find(Key('H')); + static constexpr const_iterator resultI = data.find(Key('I')); + static constexpr const_iterator resultJ = data.find(Key('J')); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); @@ -670,16 +663,16 @@ namespace value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; #endif - static constexpr Data::const_iterator resultA = data.find('A'); - static constexpr Data::const_iterator resultB = data.find('B'); - static constexpr Data::const_iterator resultC = data.find('C'); - static constexpr Data::const_iterator resultD = data.find('D'); - static constexpr Data::const_iterator resultE = data.find('E'); - static constexpr Data::const_iterator resultF = data.find('F'); - static constexpr Data::const_iterator resultG = data.find('G'); - static constexpr Data::const_iterator resultH = data.find('H'); - static constexpr Data::const_iterator resultI = data.find('I'); - static constexpr Data::const_iterator resultJ = data.find('J'); + static constexpr const_iterator resultA = data.find('A'); + static constexpr const_iterator resultB = data.find('B'); + static constexpr const_iterator resultC = data.find('C'); + static constexpr const_iterator resultD = data.find('D'); + static constexpr const_iterator resultE = data.find('E'); + static constexpr const_iterator resultF = data.find('F'); + static constexpr const_iterator resultG = data.find('G'); + static constexpr const_iterator resultH = data.find('H'); + static constexpr const_iterator resultI = data.find('I'); + static constexpr const_iterator resultJ = data.find('J'); #ifdef TEST_GREATER_THAN CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); diff --git a/test/test_const_multimap_ext.cpp b/test/test_const_multimap_ext.cpp new file mode 100644 index 00000000..b01e475c --- /dev/null +++ b/test/test_const_multimap_ext.cpp @@ -0,0 +1,1495 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2025 John Wellbelove, rlindeman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the 'Software'), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include "unit_test_framework.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "etl/const_multimap.h" +#include "etl/string.h" + +#include "data.h" + +namespace +{ + static const size_t Max_Size = 10UL; + + //************************************************************************* + // The key type + //************************************************************************* + struct Key + { + // Default constructor + constexpr Key() + : k(0) + { + } + + // Construct from char key + constexpr explicit Key(char k_) + : k(k_) + { + } + + char k; + }; + + // Less-than operator for Key < Key + constexpr bool operator <(const Key& lhs, const Key& rhs) noexcept + { + return (lhs.k < rhs.k); + } + + // Less-than operator for Key < char + constexpr bool operator <(const Key& lhs, char rhs) noexcept + { + return (lhs.k < rhs); + } + + // Less-than operator for char < Key + constexpr bool operator <(char lhs, const Key& rhs) noexcept + { + return (lhs < rhs.k); + } + + // Greater-than operator for char > Key + constexpr bool operator ==(const Key& lhs, const Key& rhs) noexcept + { + return (lhs.k == rhs.k); + } + +#define TEST_GREATER_THAN +#ifdef TEST_GREATER_THAN + using Data = etl::const_multimap_ext>; + using IData = etl::iconst_multimap>; + using DataTransparentComparator = etl::const_multimap_ext>; + using IDataTransparentComparator = etl::iconst_multimap>; +#else + using Data = etl::const_multimap_ext>; + using IData = etl::iconst_multimap>; + using DataTransparentComparator = etl::const_multimap_ext>; + using IDataTransparentComparator = etl::iconst_multimap>; +#endif + + using value_type = Data::value_type; + using key_type = Data::key_type; + using mapped_type = Data::mapped_type; + using const_iterator = Data::const_iterator; + using span_type = etl::span; + + SUITE(test_const_multimap) + { + //************************************************************************* + TEST(test_default_constructor) + { + static const Data data; + + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == 0UL); + CHECK_TRUE(empty); + CHECK_FALSE(full); + CHECK_TRUE(capacity == 0); + CHECK_TRUE(max_size == 0); + CHECK_TRUE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_min_size_from_span) + { + static const value_type values[]{value_type{Key('A'), 0}}; + static const etl::span span(values); + static const Data data{ span }; + + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == 1U); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == span.size()); + CHECK_TRUE(max_size == span.size()); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_max_size_from_span) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const span_type span(values); + static const Data data{ span }; + + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == Max_Size); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == Max_Size); + CHECK_TRUE(max_size == Max_Size); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_max_size_from_array) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == Max_Size); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == Max_Size); + CHECK_TRUE(max_size == Max_Size); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_min_size) + { + static const value_type values[]{value_type{Key('A'), 0}}; + static const Data data{ values }; + + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == 1U); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == 1); + CHECK_TRUE(max_size == 1); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_max_size) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == Max_Size); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == Max_Size); + CHECK_TRUE(max_size == Max_Size); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + // Enable to check static_assert "Number of elements exceeds capacity" + //************************************************************************* + //TEST(test_constructor_excess_size) + //{ + // static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + // value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G')), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 }, + // value_type{Key('K'), 10 } }; + // + // static const Data data{ values }; + //} + +#if ETL_USING_CPP17 + //************************************************************************* + TEST(test_cpp17_deduced_constructor_from_span) + { + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + static const etl::span span(values); + static const etl::const_multimap_ext data{ span }; + + etl::const_multimap check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + CHECK_TRUE(data.is_valid()); + CHECK_TRUE(data.size() == Max_Size); + CHECK_FALSE(data.empty()); + CHECK_TRUE(data.full()); + CHECK_TRUE(data.capacity() == Max_Size); + CHECK_TRUE(data.max_size() == Max_Size); + CHECK_FALSE(data.begin() == data.end()); + } + + //************************************************************************* + TEST(test_cpp17_deduced_constructor_from_array) + { + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + + static const etl::const_multimap_ext data{ values }; + + etl::const_multimap check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + CHECK_TRUE(data.is_valid()); + CHECK_TRUE(data.size() == Max_Size); + CHECK_FALSE(data.empty()); + CHECK_TRUE(data.full()); + CHECK_TRUE(data.capacity() == Max_Size); + CHECK_TRUE(data.max_size() == Max_Size); + CHECK_FALSE(data.begin() == data.end()); + } +#endif + + //************************************************************************* + TEST(test_begin_const) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + CHECK_TRUE(data.is_valid()); + static const auto value = *data.begin(); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE((value_type{ Key('J'), 9 }) == value); +#else + CHECK_TRUE((value_type{ Key('A'), 0 }) == value); +#endif + } + + //************************************************************************* + TEST(test_end_const) + { + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data{ values }; + + static const const_iterator end_itr = data.end(); + + CHECK_TRUE(end_itr == (data.begin() + data.size())); + } + + //************************************************************************* + TEST(test_equal_range_const) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const ETL_OR_STD::pair resultA = data.equal_range(Key('A')); + static const ETL_OR_STD::pair resultB = data.equal_range(Key('B')); + static const ETL_OR_STD::pair resultC = data.equal_range(Key('C')); + static const ETL_OR_STD::pair resultD = data.equal_range(Key('D')); + static const ETL_OR_STD::pair resultE = data.equal_range(Key('E')); + static const ETL_OR_STD::pair resultF = data.equal_range(Key('F')); + static const ETL_OR_STD::pair resultG = data.equal_range(Key('G')); + static const ETL_OR_STD::pair resultH = data.equal_range(Key('H')); + static const ETL_OR_STD::pair resultI = data.equal_range(Key('I')); + static const ETL_OR_STD::pair resultJ = data.equal_range(Key('J')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(10, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ.second))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(1, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultJ.second))); +#endif + } + + //************************************************************************* + TEST(test_equal_range_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const ETL_OR_STD::pair resultA = data.equal_range('A'); + static const ETL_OR_STD::pair resultB = data.equal_range('B'); + static const ETL_OR_STD::pair resultC = data.equal_range('C'); + static const ETL_OR_STD::pair resultD = data.equal_range('D'); + static const ETL_OR_STD::pair resultE = data.equal_range('E'); + static const ETL_OR_STD::pair resultF = data.equal_range('F'); + static const ETL_OR_STD::pair resultG = data.equal_range('G'); + static const ETL_OR_STD::pair resultH = data.equal_range('H'); + static const ETL_OR_STD::pair resultI = data.equal_range('I'); + static const ETL_OR_STD::pair resultJ = data.equal_range('J'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(10, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ.second))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(1, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultJ.second))); +#endif + } + + //************************************************************************* + TEST(test_lower_bound_const) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const const_iterator resultA = data.lower_bound(Key('A')); + static const const_iterator resultB = data.lower_bound(Key('B')); + static const const_iterator resultC = data.lower_bound(Key('C')); + static const const_iterator resultD = data.lower_bound(Key('D')); + static const const_iterator resultE = data.lower_bound(Key('E')); + static const const_iterator resultF = data.lower_bound(Key('F')); + static const const_iterator resultG = data.lower_bound(Key('G')); + static const const_iterator resultH = data.lower_bound(Key('H')); + static const const_iterator resultI = data.lower_bound(Key('I')); + static const const_iterator resultJ = data.lower_bound(Key('J')); + static const const_iterator resultK = data.lower_bound(Key('K')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_lower_bound_const_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const const_iterator resultA = data.lower_bound('A'); + static const const_iterator resultB = data.lower_bound('B'); + static const const_iterator resultC = data.lower_bound('C'); + static const const_iterator resultD = data.lower_bound('D'); + static const const_iterator resultE = data.lower_bound('E'); + static const const_iterator resultF = data.lower_bound('F'); + static const const_iterator resultG = data.lower_bound('G'); + static const const_iterator resultH = data.lower_bound('H'); + static const const_iterator resultI = data.lower_bound('I'); + static const const_iterator resultJ = data.lower_bound('J'); + static const const_iterator resultK = data.lower_bound('K'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_upper_bound_const) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const const_iterator resultA = data.upper_bound(Key('A')); + static const const_iterator resultB = data.upper_bound(Key('B')); + static const const_iterator resultC = data.upper_bound(Key('C')); + static const const_iterator resultD = data.upper_bound(Key('D')); + static const const_iterator resultE = data.upper_bound(Key('E')); + static const const_iterator resultF = data.upper_bound(Key('F')); + static const const_iterator resultG = data.upper_bound(Key('G')); + static const const_iterator resultH = data.upper_bound(Key('H')); + static const const_iterator resultI = data.upper_bound(Key('I')); + static const const_iterator resultJ = data.upper_bound(Key('J')); + static const const_iterator resultK = data.upper_bound(Key('K')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(1, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_upper_bound_const_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const const_iterator resultA = data.upper_bound('A'); + static const const_iterator resultB = data.upper_bound('B'); + static const const_iterator resultC = data.upper_bound('C'); + static const const_iterator resultD = data.upper_bound('D'); + static const const_iterator resultE = data.upper_bound('E'); + static const const_iterator resultF = data.upper_bound('F'); + static const const_iterator resultG = data.upper_bound('G'); + static const const_iterator resultH = data.upper_bound('H'); + static const const_iterator resultI = data.upper_bound('I'); + static const const_iterator resultJ = data.upper_bound('J'); + static const const_iterator resultK = data.upper_bound('K'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(1, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_count_const) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + CHECK_EQUAL(1, data.count(Key('A'))); + CHECK_EQUAL(1, data.count(Key('B'))); + CHECK_EQUAL(1, data.count(Key('C'))); + CHECK_EQUAL(1, data.count(Key('D'))); + CHECK_EQUAL(1, data.count(Key('E'))); + CHECK_EQUAL(1, data.count(Key('F'))); + CHECK_EQUAL(3, data.count(Key('G'))); + CHECK_EQUAL(0, data.count(Key('H'))); + CHECK_EQUAL(0, data.count(Key('I'))); + CHECK_EQUAL(1, data.count(Key('J'))); + CHECK_EQUAL(0, data.count(Key('K'))); + } + + //************************************************************************* + TEST(test_count_const_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const DataTransparentComparator data{ values }; + + CHECK_EQUAL(1, data.count('A')); + CHECK_EQUAL(1, data.count('B')); + CHECK_EQUAL(1, data.count('C')); + CHECK_EQUAL(1, data.count('D')); + CHECK_EQUAL(1, data.count('E')); + CHECK_EQUAL(1, data.count('F')); + CHECK_EQUAL(3, data.count('G')); + CHECK_EQUAL(0, data.count('H')); + CHECK_EQUAL(0, data.count('I')); + CHECK_EQUAL(1, data.count('J')); + CHECK_EQUAL(0, data.count('K')); + } + + //************************************************************************* + TEST(test_const_iterator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + const_iterator itr = data.begin(); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE((value_type{Key('J'), 9 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 8 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 7 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 6 }) == *itr++); + CHECK_TRUE((value_type{Key('F'), 5 }) == *itr++); + CHECK_TRUE((value_type{Key('E'), 4 }) == *itr++); + CHECK_TRUE((value_type{Key('D'), 3 }) == *itr++); + CHECK_TRUE((value_type{Key('C'), 2 }) == *itr++); + CHECK_TRUE((value_type{Key('B'), 1 }) == *itr++); + CHECK_TRUE((value_type{Key('A'), 0 }) == *itr++); + CHECK_TRUE(itr == data.end()); +#else + CHECK_TRUE((value_type{Key('A'), 0 }) == *itr++); + CHECK_TRUE((value_type{Key('B'), 1 }) == *itr++); + CHECK_TRUE((value_type{Key('C'), 2 }) == *itr++); + CHECK_TRUE((value_type{Key('D'), 3 }) == *itr++); + CHECK_TRUE((value_type{Key('E'), 4 }) == *itr++); + CHECK_TRUE((value_type{Key('F'), 5 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 6 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 7 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 8 }) == *itr++); + CHECK_TRUE((value_type{Key('J'), 9 }) == *itr++); + CHECK_TRUE(itr == data.end()); +#endif + } + + //************************************************************************* + TEST(test_find_const) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const const_iterator resultA = data.find(Key('A')); + static const const_iterator resultB = data.find(Key('B')); + static const const_iterator resultC = data.find(Key('C')); + static const const_iterator resultD = data.find(Key('D')); + static const const_iterator resultE = data.find(Key('E')); + static const const_iterator resultF = data.find(Key('F')); + static const const_iterator resultG = data.find(Key('G')); + static const const_iterator resultH = data.find(Key('H')); + static const const_iterator resultI = data.find(Key('I')); + static const const_iterator resultJ = data.find(Key('J')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); +#endif + } + + //************************************************************************* + TEST(test_find_const_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const const_iterator resultA = data.find('A'); + static const const_iterator resultB = data.find('B'); + static const const_iterator resultC = data.find('C'); + static const const_iterator resultD = data.find('D'); + static const const_iterator resultE = data.find('E'); + static const const_iterator resultF = data.find('F'); + static const const_iterator resultG = data.find('G'); + static const const_iterator resultH = data.find('H'); + static const const_iterator resultI = data.find('I'); + static const const_iterator resultJ = data.find('J'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); +#endif + } + + //************************************************************************* + TEST(test_contains_const) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const Data data{ values }; + + static const bool containsA = data.contains(Key('A')); + static const bool containsB = data.contains(Key('B')); + static const bool containsC = data.contains(Key('C')); + static const bool containsD = data.contains(Key('D')); + static const bool containsE = data.contains(Key('E')); + static const bool containsF = data.contains(Key('F')); + static const bool containsG = data.contains(Key('G')); + static const bool containsH = data.contains(Key('H')); + static const bool containsI = data.contains(Key('I')); + static const bool containsJ = data.contains(Key('J')); + static const bool containsK = data.contains(Key('K')); + + CHECK_TRUE(containsA); + CHECK_TRUE(containsB); + CHECK_TRUE(containsC); + CHECK_TRUE(containsD); + CHECK_TRUE(containsE); + CHECK_TRUE(containsF); + CHECK_TRUE(containsG); + CHECK_FALSE(containsH); + CHECK_FALSE(containsI); + CHECK_TRUE(containsJ); + CHECK_FALSE(containsK); + } + + //************************************************************************* + TEST(test_contains_with_transparent_comparator_const) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const DataTransparentComparator data{ values }; + + static const bool containsA = data.contains('A'); + static const bool containsB = data.contains('B'); + static const bool containsC = data.contains('C'); + static const bool containsD = data.contains('D'); + static const bool containsE = data.contains('E'); + static const bool containsF = data.contains('F'); + static const bool containsG = data.contains('G'); + static const bool containsH = data.contains('H'); + static const bool containsI = data.contains('I'); + static const bool containsJ = data.contains('J'); + static const bool containsK = data.contains('K'); + + CHECK_TRUE(containsA); + CHECK_TRUE(containsB); + CHECK_TRUE(containsC); + CHECK_TRUE(containsD); + CHECK_TRUE(containsE); + CHECK_TRUE(containsF); + CHECK_TRUE(containsG); + CHECK_FALSE(containsH); + CHECK_FALSE(containsI); + CHECK_TRUE(containsJ); + CHECK_FALSE(containsK); + } + + //************************************************************************* + TEST(test_key_comp_const) + { + static const Data data; + static const Data::key_compare compare = data.key_comp(); + + static const bool compareAA = compare(Key{ 'A' }, Key{ 'A' }); + static const bool compareBA = compare(Key{ 'B' }, Key{ 'A' }); + static const bool compareAB = compare(Key{ 'A' }, Key{ 'B' }); + + #ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA); + CHECK_TRUE(compareBA); + CHECK_FALSE(compareAB); + #else + CHECK_FALSE(compareAA); + CHECK_FALSE(compareBA); + CHECK_TRUE(compareAB); + #endif + } + + //************************************************************************* + TEST(test_key_comp_const_transparent_comparator) + { + static const DataTransparentComparator data; + static const DataTransparentComparator::key_compare compare = data.key_comp(); + + static const bool compareAA = compare('A', 'A'); + static const bool compareBA = compare('B', 'A'); + static const bool compareAB = compare('A', 'B'); + + #ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA); + CHECK_TRUE(compareBA); + CHECK_FALSE(compareAB); + #else + CHECK_FALSE(compareAA); + CHECK_FALSE(compareBA); + CHECK_TRUE(compareAB); + #endif + } + + //************************************************************************* + TEST(test_value_comp_const) + { + static const Data data; + static const Data::value_compare compare = data.value_comp(); + + static const bool compareAA1 = compare(value_type{ Key{ 'A' }, 0 }, value_type{ Key{ 'A' }, 0 }); + static const bool compareAA2 = compare(value_type{ Key{ 'A' }, 0 }, Key{ 'A' }); + static const bool compareAA3 = compare(Key{ 'A' }, value_type{ Key{ 'A' }, 0 }); + + static const bool compareBA1 = compare(value_type{ Key{ 'B' }, 0 }, value_type{ Key{ 'A' }, 0 }); + static const bool compareBA2 = compare(value_type{ Key{ 'B' }, 0 }, Key{ 'A' }); + static const bool compareBA3 = compare(Key{ 'B' }, value_type{ Key{ 'A' }, 0 }); + + static const bool compareAB1 = compare(value_type{ Key{ 'A' }, 0 }, value_type{ Key{ 'B' }, 0 }); + static const bool compareAB2 = compare(value_type{ Key{ 'A' }, 0 }, Key{ 'B' }); + static const bool compareAB3 = compare(Key{ 'A' }, value_type{ Key{ 'B' }, 0 });; + + #ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_TRUE(compareBA1); + CHECK_TRUE(compareBA2); + CHECK_TRUE(compareBA3); + + CHECK_FALSE(compareAB1); + CHECK_FALSE(compareAB2); + CHECK_FALSE(compareAB3); + #else + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_FALSE(compareBA1); + CHECK_FALSE(compareBA2); + CHECK_FALSE(compareBA3); + + CHECK_TRUE(compareAB1); + CHECK_TRUE(compareAB2); + CHECK_TRUE(compareAB3); + #endif + } + + //************************************************************************* + TEST(test_value_comp_const_transparent_comparator) + { + static const DataTransparentComparator data; + static const DataTransparentComparator::value_compare compare = data.value_comp(); + + static const bool compareAA1 = compare(value_type{ 'A', 0 }, value_type{ 'A', 0 }); + static const bool compareAA2 = compare(value_type{ 'A', 0 }, 'A'); + static const bool compareAA3 = compare('A', value_type{ 'A', 0 }); + + static const bool compareBA1 = compare(value_type{ 'B', 0 }, value_type{ 'A', 0 }); + static const bool compareBA2 = compare(value_type{ 'B', 0 }, 'A'); + static const bool compareBA3 = compare('B', value_type{ 'A', 0 }); + + static const bool compareAB1 = compare(value_type{ 'A', 0 }, value_type{ 'B', 0 }); + static const bool compareAB2 = compare(value_type{ 'A', 0 }, 'B'); + static const bool compareAB3 = compare('A', value_type{ 'B', 0 });; + + #ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_TRUE(compareBA1); + CHECK_TRUE(compareBA2); + CHECK_TRUE(compareBA3); + + CHECK_FALSE(compareAB1); + CHECK_FALSE(compareAB2); + CHECK_FALSE(compareAB3); + #else + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_FALSE(compareBA1); + CHECK_FALSE(compareBA2); + CHECK_FALSE(compareBA3); + + CHECK_TRUE(compareAB1); + CHECK_TRUE(compareAB2); + CHECK_TRUE(compareAB3); + #endif + } + + //************************************************************************* + TEST(test_equal) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data1{values1}; + static const Data data2{values2}; + static const Data data3{values3}; + + static const bool equal12 = (data1 == data2); + static const bool equal13 = (data1 == data3); + + CHECK_TRUE(equal12); + CHECK_FALSE(equal13); + } + + //************************************************************************* + TEST(test_equal_with_transparent_comparator) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const DataTransparentComparator data1{values1}; + static const DataTransparentComparator data2{values2}; + static const DataTransparentComparator data3{values3}; + + static const bool equal12 = (data1 == data2); + static const bool equal13 = (data1 == data3); + + CHECK_TRUE(equal12); + CHECK_FALSE(equal13); + } + + //************************************************************************* + TEST(test_not_equal) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data1{values1}; + static const Data data2{values2}; + static const Data data3{values3}; + + static const bool not_equal12 = (data1 != data2); + static const bool not_equal13 = (data1 != data3); + + CHECK_FALSE(not_equal12); + CHECK_TRUE(not_equal13); + } + + //************************************************************************* + TEST(test_not_equal_with_transparent_comparator) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const DataTransparentComparator data1{values1}; + static const DataTransparentComparator data2{values2}; + static const DataTransparentComparator data3{values3}; + + static const bool not_equal12 = (data1 != data2); + static const bool not_equal13 = (data1 != data3); + + CHECK_FALSE(not_equal12); + CHECK_TRUE(not_equal13); + } + + //************************************************************************* + TEST(test_less_than) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data1{values1}; + static const Data data2{values2}; + static const Data data3{values3}; + + static const bool less_than12 = (data1 < data2); + static const bool less_than23 = (data2 < data3); + static const bool less_than21 = (data2 < data1); + static const bool less_than32 = (data3 < data2); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than12); + CHECK_FALSE(less_than23); + CHECK_TRUE(less_than21); + CHECK_TRUE(less_than32); +#else + CHECK_TRUE(less_than12); + CHECK_TRUE(less_than23); + CHECK_FALSE(less_than21); + CHECK_FALSE(less_than32); +#endif + } + + //************************************************************************* + TEST(test_less_than_with_transparent_comparator) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const DataTransparentComparator data1{values1}; + static const DataTransparentComparator data2{values2}; + static const DataTransparentComparator data3{values3}; + + static const bool less_than12 = (data1 < data2); + static const bool less_than23 = (data2 < data3); + static const bool less_than21 = (data2 < data1); + static const bool less_than32 = (data3 < data2); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than12); + CHECK_FALSE(less_than23); + CHECK_TRUE(less_than21); + CHECK_TRUE(less_than32); +#else + CHECK_TRUE(less_than12); + CHECK_TRUE(less_than23); + CHECK_FALSE(less_than21); + CHECK_FALSE(less_than32); +#endif + } + + //************************************************************************* + TEST(test_less_than_equal) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data1{values1}; + static const Data data2{values2}; + static const Data data3{values3}; + + static const bool less_than_equal12 = (data1 <= data2); + static const bool less_than_equal23 = (data2 <= data3); + static const bool less_than_equal21 = (data2 <= data1); + static const bool less_than_equal32 = (data3 <= data2); + static const bool less_than_equal11 = (data1 <= data1); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than_equal12); + CHECK_FALSE(less_than_equal23); + CHECK_TRUE(less_than_equal21); + CHECK_TRUE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#else + CHECK_TRUE(less_than_equal12); + CHECK_TRUE(less_than_equal23); + CHECK_FALSE(less_than_equal21); + CHECK_FALSE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#endif + } + + //************************************************************************* + TEST(test_less_than_equal_with_transparent_comparator) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const DataTransparentComparator data1{values1}; + static const DataTransparentComparator data2{values2}; + static const DataTransparentComparator data3{values3}; + + static const bool less_than_equal12 = (data1 <= data2); + static const bool less_than_equal23 = (data2 <= data3); + static const bool less_than_equal21 = (data2 <= data1); + static const bool less_than_equal32 = (data3 <= data2); + static const bool less_than_equal11 = (data1 <= data1); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than_equal12); + CHECK_FALSE(less_than_equal23); + CHECK_TRUE(less_than_equal21); + CHECK_TRUE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#else + CHECK_TRUE(less_than_equal12); + CHECK_TRUE(less_than_equal23); + CHECK_FALSE(less_than_equal21); + CHECK_FALSE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#endif + } + + //************************************************************************* + TEST(test_greater_than) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data1{values1}; + static const Data data2{values2}; + static const Data data3{values3}; + + static const bool greater_than12 = (data1 > data2); + static const bool greater_than23 = (data2 > data3); + static const bool greater_than21 = (data2 > data1); + static const bool greater_than32 = (data3 > data2); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than12); + CHECK_TRUE(greater_than23); + CHECK_FALSE(greater_than21); + CHECK_FALSE(greater_than32); +#else + CHECK_FALSE(greater_than12); + CHECK_FALSE(greater_than23); + CHECK_TRUE(greater_than21); + CHECK_TRUE(greater_than32); +#endif + } + + //************************************************************************* + TEST(test_greater_than_with_transparent_comparator) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const DataTransparentComparator data1{values1}; + static const DataTransparentComparator data2{values2}; + static const DataTransparentComparator data3{values3}; + + static const bool greater_than12 = (data1 > data2); + static const bool greater_than23 = (data2 > data3); + static const bool greater_than21 = (data2 > data1); + static const bool greater_than32 = (data3 > data2); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than12); + CHECK_TRUE(greater_than23); + CHECK_FALSE(greater_than21); + CHECK_FALSE(greater_than32); +#else + CHECK_FALSE(greater_than12); + CHECK_FALSE(greater_than23); + CHECK_TRUE(greater_than21); + CHECK_TRUE(greater_than32); +#endif + } + + //************************************************************************* + TEST(test_greater_than_equal) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const Data data1{values1}; + static const Data data2{values2}; + static const Data data3{values3}; + + static const bool greater_than_equal12 = (data1 >= data2); + static const bool greater_than_equal23 = (data2 >= data3); + static const bool greater_than_equal21 = (data2 >= data1); + static const bool greater_than_equal32 = (data3 >= data2); + static const bool greater_than_equal11 = (data1 >= data1); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than_equal12); + CHECK_TRUE(greater_than_equal23); + CHECK_FALSE(greater_than_equal21); + CHECK_FALSE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#else + CHECK_FALSE(greater_than_equal12); + CHECK_FALSE(greater_than_equal23); + CHECK_TRUE(greater_than_equal21); + CHECK_TRUE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#endif + } + + //************************************************************************* + TEST(test_greater_than_equal_with_transparent_comparator) + { + static const value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static const DataTransparentComparator data1{values1}; + static const DataTransparentComparator data2{values2}; + static const DataTransparentComparator data3{values3}; + + static const bool greater_than_equal12 = (data1 >= data2); + static const bool greater_than_equal23 = (data2 >= data3); + static const bool greater_than_equal21 = (data2 >= data1); + static const bool greater_than_equal32 = (data3 >= data2); + static const bool greater_than_equal11 = (data1 >= data1); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than_equal12); + CHECK_TRUE(greater_than_equal23); + CHECK_FALSE(greater_than_equal21); + CHECK_FALSE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#else + CHECK_FALSE(greater_than_equal12); + CHECK_FALSE(greater_than_equal23); + CHECK_TRUE(greater_than_equal21); + CHECK_TRUE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#endif + } + }; +} diff --git a/test/test_const_multimap_ext_constexpr.cpp b/test/test_const_multimap_ext_constexpr.cpp new file mode 100644 index 00000000..3f84174a --- /dev/null +++ b/test/test_const_multimap_ext_constexpr.cpp @@ -0,0 +1,1484 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2025 John Wellbelove, rlindeman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the 'Software'), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include "unit_test_framework.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "etl/const_multimap.h" +#include "etl/string.h" + +#include "data.h" + +namespace +{ + static constexpr size_t Max_Size = 10UL; + + //************************************************************************* + // The key type + //************************************************************************* + struct Key + { + // Default constructor + constexpr Key() + : k(0) + { + } + + // Construct from char key + constexpr explicit Key(char k_) + : k(k_) + { + } + + char k; + }; + + // Less-than operator for Key < Key + constexpr bool operator <(const Key& lhs, const Key& rhs) noexcept + { + return (lhs.k < rhs.k); + } + + // Less-than operator for Key < char + constexpr bool operator <(const Key& lhs, char rhs) noexcept + { + return (lhs.k < rhs); + } + + // Less-than operator for char < Key + constexpr bool operator <(char lhs, const Key& rhs) noexcept + { + return (lhs < rhs.k); + } + + // Greater-than operator for char > Key + constexpr bool operator ==(const Key& lhs, const Key& rhs) noexcept + { + return (lhs.k == rhs.k); + } + +#define TEST_GREATER_THAN +#ifdef TEST_GREATER_THAN + using Data = etl::const_multimap_ext>; + using IData = etl::iconst_multimap>; + using DataTransparentComparator = etl::const_multimap_ext>; + using IDataTransparentComparator = etl::iconst_multimap>; +#else + using Data = etl::const_multimap_ext>; + using IData = etl::iconst_multimap>; + using DataTransparentComparator = etl::const_multimap_ext>; + using IDataTransparentComparator = etl::iconst_multimap>; +#endif + + using value_type = Data::value_type; + using key_type = Data::key_type; + using mapped_type = Data::mapped_type; + using const_iterator = Data::const_iterator; + using span_type = etl::span; + + SUITE(test_const_multimap) + { + //************************************************************************* + TEST(test_default_constructor) + { + static constexpr Data data; + + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == 0UL); + CHECK_TRUE(empty); + CHECK_FALSE(full); + CHECK_TRUE(capacity == 0); + CHECK_TRUE(max_size == 0); + CHECK_TRUE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_min_size_from_span) + { + static constexpr value_type values[]{value_type{Key('A'), 0}}; + static constexpr etl::span span(values); + static constexpr Data data{ span }; + + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == 1U); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == span.size()); + CHECK_TRUE(max_size == span.size()); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_max_size_from_span) + { +#ifdef TEST_GREATER_THAN + static const value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('I'), 8 }, value_type{Key('H'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static const value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static const span_type span(values); + static const Data data{ span }; + + static const bool is_valid = data.is_valid(); + static const size_t size = data.size(); + static const bool empty = data.empty(); + static const bool full = data.full(); + static const size_t capacity = data.capacity(); + static const size_t max_size = data.max_size(); + static const const_iterator begin = data.begin(); + static const const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == Max_Size); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == Max_Size); + CHECK_TRUE(max_size == Max_Size); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_cpp17_deduced_constructor_from_span) + { + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + static constexpr etl::span span(values); + static constexpr etl::const_multimap_ext data{ span }; + + etl::const_multimap check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + CHECK_TRUE(data.is_valid()); + CHECK_TRUE(data.size() == Max_Size); + CHECK_FALSE(data.empty()); + CHECK_TRUE(data.full()); + CHECK_TRUE(data.capacity() == Max_Size); + CHECK_TRUE(data.max_size() == Max_Size); + CHECK_FALSE(data.begin() == data.end()); + } + + //************************************************************************* + TEST(test_cpp17_deduced_constructor_from_array) + { + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr etl::const_multimap_ext data{ values }; + + etl::const_multimap check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + CHECK_TRUE(data.is_valid()); + CHECK_TRUE(data.size() == Max_Size); + CHECK_FALSE(data.empty()); + CHECK_TRUE(data.full()); + CHECK_TRUE(data.capacity() == Max_Size); + CHECK_TRUE(data.max_size() == Max_Size); + CHECK_FALSE(data.begin() == data.end()); + } + + //************************************************************************* + TEST(test_constructor_min_size) + { + static constexpr value_type values[]{value_type{Key('A'), 0}}; + static constexpr Data data{ values }; + + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == 1U); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == 1); + CHECK_TRUE(max_size == 1); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + TEST(test_constructor_max_size) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr bool is_valid = data.is_valid(); + static constexpr size_t size = data.size(); + static constexpr bool empty = data.empty(); + static constexpr bool full = data.full(); + static constexpr size_t capacity = data.capacity(); + static constexpr size_t max_size = data.max_size(); + static constexpr const_iterator begin = data.begin(); + static constexpr const_iterator end = data.end(); + + CHECK_TRUE(is_valid); + CHECK_TRUE(size == Max_Size); + CHECK_FALSE(empty); + CHECK_TRUE(full); + CHECK_TRUE(capacity == Max_Size); + CHECK_TRUE(max_size == Max_Size); + CHECK_FALSE(begin == end); + } + + //************************************************************************* + // Enable to check static_assert "Number of elements exceeds capacity" + //************************************************************************* + //TEST(test_constructor_excess_size) + //{ + // static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + // value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G')), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 }, + // value_type{Key('K'), 10 } }; + // + // static constexpr Data data{ values }; + //} + +#if ETL_USING_CPP17 + //************************************************************************* + TEST(test_cpp17_deduced_constructor) + { + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr etl::const_multimap_ext data{ values }; + + etl::const_multimap check{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + CHECK_TRUE(data.is_valid()); + CHECK_TRUE(data.size() == Max_Size); + CHECK_FALSE(data.empty()); + CHECK_TRUE(data.full()); + CHECK_TRUE(data.capacity() == Max_Size); + CHECK_TRUE(data.max_size() == Max_Size); + CHECK_FALSE(data.begin() == data.end()); + } +#endif + + //************************************************************************* + TEST(test_begin_const) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + CHECK_TRUE(data.is_valid()); + static constexpr auto value = *data.begin(); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE((value_type{ Key('J'), 9 }) == value); +#else + CHECK_TRUE((value_type{ Key('A'), 0 }) == value); +#endif + } + + //************************************************************************* + TEST(test_end_const) + { + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data{ values }; + + static constexpr const_iterator end_itr = data.end(); + + CHECK_TRUE(end_itr == (data.begin() + data.size())); + } + + //************************************************************************* + TEST(test_equal_range_const) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr ETL_OR_STD::pair resultA = data.equal_range(Key('A')); + static constexpr ETL_OR_STD::pair resultB = data.equal_range(Key('B')); + static constexpr ETL_OR_STD::pair resultC = data.equal_range(Key('C')); + static constexpr ETL_OR_STD::pair resultD = data.equal_range(Key('D')); + static constexpr ETL_OR_STD::pair resultE = data.equal_range(Key('E')); + static constexpr ETL_OR_STD::pair resultF = data.equal_range(Key('F')); + static constexpr ETL_OR_STD::pair resultG = data.equal_range(Key('G')); + static constexpr ETL_OR_STD::pair resultH = data.equal_range(Key('H')); + static constexpr ETL_OR_STD::pair resultI = data.equal_range(Key('I')); + static constexpr ETL_OR_STD::pair resultJ = data.equal_range(Key('J')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(10, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ.second))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(1, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultJ.second))); +#endif + } + + //************************************************************************* + TEST(test_equal_range_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr ETL_OR_STD::pair resultA = data.equal_range('A'); + static constexpr ETL_OR_STD::pair resultB = data.equal_range('B'); + static constexpr ETL_OR_STD::pair resultC = data.equal_range('C'); + static constexpr ETL_OR_STD::pair resultD = data.equal_range('D'); + static constexpr ETL_OR_STD::pair resultE = data.equal_range('E'); + static constexpr ETL_OR_STD::pair resultF = data.equal_range('F'); + static constexpr ETL_OR_STD::pair resultG = data.equal_range('G'); + static constexpr ETL_OR_STD::pair resultH = data.equal_range('H'); + static constexpr ETL_OR_STD::pair resultI = data.equal_range('I'); + static constexpr ETL_OR_STD::pair resultJ = data.equal_range('J'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(10, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ.second))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA.first))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB.first))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC.first))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD.first))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE.first))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF.first))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI.first))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ.first))); + + CHECK_EQUAL(1, (std::distance(data.begin(), resultA.second))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB.second))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC.second))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultD.second))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE.second))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultG.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH.second))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI.second))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultJ.second))); +#endif + } + + //************************************************************************* + TEST(test_lower_bound_const) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr const_iterator resultA = data.lower_bound(Key('A')); + static constexpr const_iterator resultB = data.lower_bound(Key('B')); + static constexpr const_iterator resultC = data.lower_bound(Key('C')); + static constexpr const_iterator resultD = data.lower_bound(Key('D')); + static constexpr const_iterator resultE = data.lower_bound(Key('E')); + static constexpr const_iterator resultF = data.lower_bound(Key('F')); + static constexpr const_iterator resultG = data.lower_bound(Key('G')); + static constexpr const_iterator resultH = data.lower_bound(Key('H')); + static constexpr const_iterator resultI = data.lower_bound(Key('I')); + static constexpr const_iterator resultJ = data.lower_bound(Key('J')); + static constexpr const_iterator resultK = data.lower_bound(Key('K')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_lower_bound_const_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr const_iterator resultA = data.lower_bound('A'); + static constexpr const_iterator resultB = data.lower_bound('B'); + static constexpr const_iterator resultC = data.lower_bound('C'); + static constexpr const_iterator resultD = data.lower_bound('D'); + static constexpr const_iterator resultE = data.lower_bound('E'); + static constexpr const_iterator resultF = data.lower_bound('F'); + static constexpr const_iterator resultG = data.lower_bound('G'); + static constexpr const_iterator resultH = data.lower_bound('H'); + static constexpr const_iterator resultI = data.lower_bound('I'); + static constexpr const_iterator resultJ = data.lower_bound('J'); + static constexpr const_iterator resultK = data.lower_bound('K'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_upper_bound_const) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr const_iterator resultA = data.upper_bound(Key('A')); + static constexpr const_iterator resultB = data.upper_bound(Key('B')); + static constexpr const_iterator resultC = data.upper_bound(Key('C')); + static constexpr const_iterator resultD = data.upper_bound(Key('D')); + static constexpr const_iterator resultE = data.upper_bound(Key('E')); + static constexpr const_iterator resultF = data.upper_bound(Key('F')); + static constexpr const_iterator resultG = data.upper_bound(Key('G')); + static constexpr const_iterator resultH = data.upper_bound(Key('H')); + static constexpr const_iterator resultI = data.upper_bound(Key('I')); + static constexpr const_iterator resultJ = data.upper_bound(Key('J')); + static constexpr const_iterator resultK = data.upper_bound(Key('K')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(1, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_upper_bound_const_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr const_iterator resultA = data.upper_bound('A'); + static constexpr const_iterator resultB = data.upper_bound('B'); + static constexpr const_iterator resultC = data.upper_bound('C'); + static constexpr const_iterator resultD = data.upper_bound('D'); + static constexpr const_iterator resultE = data.upper_bound('E'); + static constexpr const_iterator resultF = data.upper_bound('F'); + static constexpr const_iterator resultG = data.upper_bound('G'); + static constexpr const_iterator resultH = data.upper_bound('H'); + static constexpr const_iterator resultI = data.upper_bound('I'); + static constexpr const_iterator resultJ = data.upper_bound('J'); + static constexpr const_iterator resultK = data.upper_bound('K'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(10, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultK))); +#else + CHECK_EQUAL(1, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultJ))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultK))); +#endif + } + + //************************************************************************* + TEST(test_count_const) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + CHECK_EQUAL(1, data.count(Key('A'))); + CHECK_EQUAL(1, data.count(Key('B'))); + CHECK_EQUAL(1, data.count(Key('C'))); + CHECK_EQUAL(1, data.count(Key('D'))); + CHECK_EQUAL(1, data.count(Key('E'))); + CHECK_EQUAL(1, data.count(Key('F'))); + CHECK_EQUAL(3, data.count(Key('G'))); + CHECK_EQUAL(0, data.count(Key('H'))); + CHECK_EQUAL(0, data.count(Key('I'))); + CHECK_EQUAL(1, data.count(Key('J'))); + CHECK_EQUAL(0, data.count(Key('K'))); + } + + //************************************************************************* + TEST(test_count_const_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + CHECK_EQUAL(1, data.count('A')); + CHECK_EQUAL(1, data.count('B')); + CHECK_EQUAL(1, data.count('C')); + CHECK_EQUAL(1, data.count('D')); + CHECK_EQUAL(1, data.count('E')); + CHECK_EQUAL(1, data.count('F')); + CHECK_EQUAL(3, data.count('G')); + CHECK_EQUAL(0, data.count('H')); + CHECK_EQUAL(0, data.count('I')); + CHECK_EQUAL(1, data.count('J')); + CHECK_EQUAL(0, data.count('K')); + } + + //************************************************************************* + TEST(test_const_iterator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + const_iterator itr = data.begin(); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE((value_type{Key('J'), 9 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 8 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 7 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 6 }) == *itr++); + CHECK_TRUE((value_type{Key('F'), 5 }) == *itr++); + CHECK_TRUE((value_type{Key('E'), 4 }) == *itr++); + CHECK_TRUE((value_type{Key('D'), 3 }) == *itr++); + CHECK_TRUE((value_type{Key('C'), 2 }) == *itr++); + CHECK_TRUE((value_type{Key('B'), 1 }) == *itr++); + CHECK_TRUE((value_type{Key('A'), 0 }) == *itr++); + CHECK_TRUE(itr == data.end()); +#else + CHECK_TRUE((value_type{Key('A'), 0 }) == *itr++); + CHECK_TRUE((value_type{Key('B'), 1 }) == *itr++); + CHECK_TRUE((value_type{Key('C'), 2 }) == *itr++); + CHECK_TRUE((value_type{Key('D'), 3 }) == *itr++); + CHECK_TRUE((value_type{Key('E'), 4 }) == *itr++); + CHECK_TRUE((value_type{Key('F'), 5 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 6 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 7 }) == *itr++); + CHECK_TRUE((value_type{Key('G'), 8 }) == *itr++); + CHECK_TRUE((value_type{Key('J'), 9 }) == *itr++); + CHECK_TRUE(itr == data.end()); +#endif + } + + //************************************************************************* + TEST(test_find_const) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr const_iterator resultA = data.find(Key('A')); + static constexpr const_iterator resultB = data.find(Key('B')); + static constexpr const_iterator resultC = data.find(Key('C')); + static constexpr const_iterator resultD = data.find(Key('D')); + static constexpr const_iterator resultE = data.find(Key('E')); + static constexpr const_iterator resultF = data.find(Key('F')); + static constexpr const_iterator resultG = data.find(Key('G')); + static constexpr const_iterator resultH = data.find(Key('H')); + static constexpr const_iterator resultI = data.find(Key('I')); + static constexpr const_iterator resultJ = data.find(Key('J')); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); +#endif + } + + //************************************************************************* + TEST(test_find_const_using_transparent_comparator) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr const_iterator resultA = data.find('A'); + static constexpr const_iterator resultB = data.find('B'); + static constexpr const_iterator resultC = data.find('C'); + static constexpr const_iterator resultD = data.find('D'); + static constexpr const_iterator resultE = data.find('E'); + static constexpr const_iterator resultF = data.find('F'); + static constexpr const_iterator resultG = data.find('G'); + static constexpr const_iterator resultH = data.find('H'); + static constexpr const_iterator resultI = data.find('I'); + static constexpr const_iterator resultJ = data.find('J'); + +#ifdef TEST_GREATER_THAN + CHECK_EQUAL(9, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(8, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(7, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(0, (std::distance(data.begin(), resultJ))); +#else + CHECK_EQUAL(0, (std::distance(data.begin(), resultA))); + CHECK_EQUAL(1, (std::distance(data.begin(), resultB))); + CHECK_EQUAL(2, (std::distance(data.begin(), resultC))); + CHECK_EQUAL(3, (std::distance(data.begin(), resultD))); + CHECK_EQUAL(4, (std::distance(data.begin(), resultE))); + CHECK_EQUAL(5, (std::distance(data.begin(), resultF))); + CHECK_EQUAL(6, (std::distance(data.begin(), resultG))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultH))); + CHECK_EQUAL(10, (std::distance(data.begin(), resultI))); + CHECK_EQUAL(9, (std::distance(data.begin(), resultJ))); +#endif + } + + //************************************************************************* + TEST(test_contains_const) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr Data data{ values }; + + static constexpr bool containsA = data.contains(Key('A')); + static constexpr bool containsB = data.contains(Key('B')); + static constexpr bool containsC = data.contains(Key('C')); + static constexpr bool containsD = data.contains(Key('D')); + static constexpr bool containsE = data.contains(Key('E')); + static constexpr bool containsF = data.contains(Key('F')); + static constexpr bool containsG = data.contains(Key('G')); + static constexpr bool containsH = data.contains(Key('H')); + static constexpr bool containsI = data.contains(Key('I')); + static constexpr bool containsJ = data.contains(Key('J')); + static constexpr bool containsK = data.contains(Key('K')); + + CHECK_TRUE(containsA); + CHECK_TRUE(containsB); + CHECK_TRUE(containsC); + CHECK_TRUE(containsD); + CHECK_TRUE(containsE); + CHECK_TRUE(containsF); + CHECK_TRUE(containsG); + CHECK_FALSE(containsH); + CHECK_FALSE(containsI); + CHECK_TRUE(containsJ); + CHECK_FALSE(containsK); + } + + //************************************************************************* + TEST(test_contains_with_transparent_comparator_const) + { +#ifdef TEST_GREATER_THAN + static constexpr value_type values[]{ value_type{Key('J'), 9 }, value_type{Key('G'), 8 }, value_type{Key('G'), 7 }, value_type{Key('G'), 6 }, value_type{Key('F'), 5 }, + value_type{Key('E'), 4 }, value_type{Key('D'), 3 }, value_type{Key('C'), 2 }, value_type{Key('B'), 1 }, value_type{Key('A'), 0 } }; +#else + static constexpr value_type values[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('G'), 7 }, value_type{Key('G'), 8 }, value_type{Key('J'), 9 } }; +#endif + + static constexpr DataTransparentComparator data{ values }; + + static constexpr bool containsA = data.contains('A'); + static constexpr bool containsB = data.contains('B'); + static constexpr bool containsC = data.contains('C'); + static constexpr bool containsD = data.contains('D'); + static constexpr bool containsE = data.contains('E'); + static constexpr bool containsF = data.contains('F'); + static constexpr bool containsG = data.contains('G'); + static constexpr bool containsH = data.contains('H'); + static constexpr bool containsI = data.contains('I'); + static constexpr bool containsJ = data.contains('J'); + static constexpr bool containsK = data.contains('K'); + + CHECK_TRUE(containsA); + CHECK_TRUE(containsB); + CHECK_TRUE(containsC); + CHECK_TRUE(containsD); + CHECK_TRUE(containsE); + CHECK_TRUE(containsF); + CHECK_TRUE(containsG); + CHECK_FALSE(containsH); + CHECK_FALSE(containsI); + CHECK_TRUE(containsJ); + CHECK_FALSE(containsK); + } + + //************************************************************************* + TEST(test_key_comp_const) + { + static constexpr Data data; + static constexpr Data::key_compare compare = data.key_comp(); + + static constexpr bool compareAA = compare(Key{ 'A' }, Key{ 'A' }); + static constexpr bool compareBA = compare(Key{ 'B' }, Key{ 'A' }); + static constexpr bool compareAB = compare(Key{ 'A' }, Key{ 'B' }); + + #ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA); + CHECK_TRUE(compareBA); + CHECK_FALSE(compareAB); + #else + CHECK_FALSE(compareAA); + CHECK_FALSE(compareBA); + CHECK_TRUE(compareAB); + #endif + } + + //************************************************************************* + TEST(test_key_comp_const_transparent_comparator) + { + static constexpr DataTransparentComparator data; + static constexpr DataTransparentComparator::key_compare compare = data.key_comp(); + + static constexpr bool compareAA = compare('A', 'A'); + static constexpr bool compareBA = compare('B', 'A'); + static constexpr bool compareAB = compare('A', 'B'); + + #ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA); + CHECK_TRUE(compareBA); + CHECK_FALSE(compareAB); + #else + CHECK_FALSE(compareAA); + CHECK_FALSE(compareBA); + CHECK_TRUE(compareAB); + #endif + } + + //************************************************************************* + TEST(test_value_comp_const) + { + static constexpr Data data; + static constexpr Data::value_compare compare = data.value_comp(); + + static constexpr bool compareAA1 = compare(value_type{ Key{ 'A' }, 0 }, value_type{ Key{ 'A' }, 0 }); + static constexpr bool compareAA2 = compare(value_type{ Key{ 'A' }, 0 }, Key{ 'A' }); + static constexpr bool compareAA3 = compare(Key{ 'A' }, value_type{ Key{ 'A' }, 0 }); + + static constexpr bool compareBA1 = compare(value_type{ Key{ 'B' }, 0 }, value_type{ Key{ 'A' }, 0 }); + static constexpr bool compareBA2 = compare(value_type{ Key{ 'B' }, 0 }, Key{ 'A' }); + static constexpr bool compareBA3 = compare(Key{ 'B' }, value_type{ Key{ 'A' }, 0 }); + + static constexpr bool compareAB1 = compare(value_type{ Key{ 'A' }, 0 }, value_type{ Key{ 'B' }, 0 }); + static constexpr bool compareAB2 = compare(value_type{ Key{ 'A' }, 0 }, Key{ 'B' }); + static constexpr bool compareAB3 = compare(Key{ 'A' }, value_type{ Key{ 'B' }, 0 });; + + #ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_TRUE(compareBA1); + CHECK_TRUE(compareBA2); + CHECK_TRUE(compareBA3); + + CHECK_FALSE(compareAB1); + CHECK_FALSE(compareAB2); + CHECK_FALSE(compareAB3); + #else + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_FALSE(compareBA1); + CHECK_FALSE(compareBA2); + CHECK_FALSE(compareBA3); + + CHECK_TRUE(compareAB1); + CHECK_TRUE(compareAB2); + CHECK_TRUE(compareAB3); + #endif + } + + //************************************************************************* + TEST(test_value_comp_const_transparent_comparator) + { + static constexpr DataTransparentComparator data; + static constexpr DataTransparentComparator::value_compare compare = data.value_comp(); + + static constexpr bool compareAA1 = compare(value_type{ 'A', 0 }, value_type{ 'A', 0 }); + static constexpr bool compareAA2 = compare(value_type{ 'A', 0 }, 'A'); + static constexpr bool compareAA3 = compare('A', value_type{ 'A', 0 }); + + static constexpr bool compareBA1 = compare(value_type{ 'B', 0 }, value_type{ 'A', 0 }); + static constexpr bool compareBA2 = compare(value_type{ 'B', 0 }, 'A'); + static constexpr bool compareBA3 = compare('B', value_type{ 'A', 0 }); + + static constexpr bool compareAB1 = compare(value_type{ 'A', 0 }, value_type{ 'B', 0 }); + static constexpr bool compareAB2 = compare(value_type{ 'A', 0 }, 'B'); + static constexpr bool compareAB3 = compare('A', value_type{ 'B', 0 });; + + #ifdef TEST_GREATER_THAN + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_TRUE(compareBA1); + CHECK_TRUE(compareBA2); + CHECK_TRUE(compareBA3); + + CHECK_FALSE(compareAB1); + CHECK_FALSE(compareAB2); + CHECK_FALSE(compareAB3); + #else + CHECK_FALSE(compareAA1); + CHECK_FALSE(compareAA2); + CHECK_FALSE(compareAA3); + + CHECK_FALSE(compareBA1); + CHECK_FALSE(compareBA2); + CHECK_FALSE(compareBA3); + + CHECK_TRUE(compareAB1); + CHECK_TRUE(compareAB2); + CHECK_TRUE(compareAB3); + #endif + } + + //************************************************************************* + TEST(test_equal) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data1{values1}; + static constexpr Data data2{values2}; + static constexpr Data data3{values3}; + + static constexpr bool equal12 = (data1 == data2); + static constexpr bool equal13 = (data1 == data3); + + CHECK_TRUE(equal12); + CHECK_FALSE(equal13); + } + + //************************************************************************* + TEST(test_equal_with_transparent_comparator) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr DataTransparentComparator data1{values1}; + static constexpr DataTransparentComparator data2{values2}; + static constexpr DataTransparentComparator data3{values3}; + + static constexpr bool equal12 = (data1 == data2); + static constexpr bool equal13 = (data1 == data3); + + CHECK_TRUE(equal12); + CHECK_FALSE(equal13); + } + + //************************************************************************* + TEST(test_not_equal) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data1{values1}; + static constexpr Data data2{values2}; + static constexpr Data data3{values3}; + + static constexpr bool not_equal12 = (data1 != data2); + static constexpr bool not_equal13 = (data1 != data3); + + CHECK_FALSE(not_equal12); + CHECK_TRUE(not_equal13); + } + + //************************************************************************* + TEST(test_not_equal_with_transparent_comparator) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 6 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr DataTransparentComparator data1{values1}; + static constexpr DataTransparentComparator data2{values2}; + static constexpr DataTransparentComparator data3{values3}; + + static constexpr bool not_equal12 = (data1 != data2); + static constexpr bool not_equal13 = (data1 != data3); + + CHECK_FALSE(not_equal12); + CHECK_TRUE(not_equal13); + } + + //************************************************************************* + TEST(test_less_than) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data1{values1}; + static constexpr Data data2{values2}; + static constexpr Data data3{values3}; + + static constexpr bool less_than12 = (data1 < data2); + static constexpr bool less_than23 = (data2 < data3); + static constexpr bool less_than21 = (data2 < data1); + static constexpr bool less_than32 = (data3 < data2); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than12); + CHECK_FALSE(less_than23); + CHECK_TRUE(less_than21); + CHECK_TRUE(less_than32); +#else + CHECK_TRUE(less_than12); + CHECK_TRUE(less_than23); + CHECK_FALSE(less_than21); + CHECK_FALSE(less_than32); +#endif + } + + //************************************************************************* + TEST(test_less_than_with_transparent_comparator) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr DataTransparentComparator data1{values1}; + static constexpr DataTransparentComparator data2{values2}; + static constexpr DataTransparentComparator data3{values3}; + + static constexpr bool less_than12 = (data1 < data2); + static constexpr bool less_than23 = (data2 < data3); + static constexpr bool less_than21 = (data2 < data1); + static constexpr bool less_than32 = (data3 < data2); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than12); + CHECK_FALSE(less_than23); + CHECK_TRUE(less_than21); + CHECK_TRUE(less_than32); +#else + CHECK_TRUE(less_than12); + CHECK_TRUE(less_than23); + CHECK_FALSE(less_than21); + CHECK_FALSE(less_than32); +#endif + } + + //************************************************************************* + TEST(test_less_than_equal) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data1{values1}; + static constexpr Data data2{values2}; + static constexpr Data data3{values3}; + + static constexpr bool less_than_equal12 = (data1 <= data2); + static constexpr bool less_than_equal23 = (data2 <= data3); + static constexpr bool less_than_equal21 = (data2 <= data1); + static constexpr bool less_than_equal32 = (data3 <= data2); + static constexpr bool less_than_equal11 = (data1 <= data1); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than_equal12); + CHECK_FALSE(less_than_equal23); + CHECK_TRUE(less_than_equal21); + CHECK_TRUE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#else + CHECK_TRUE(less_than_equal12); + CHECK_TRUE(less_than_equal23); + CHECK_FALSE(less_than_equal21); + CHECK_FALSE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#endif + } + + //************************************************************************* + TEST(test_less_than_equal_with_transparent_comparator) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr DataTransparentComparator data1{values1}; + static constexpr DataTransparentComparator data2{values2}; + static constexpr DataTransparentComparator data3{values3}; + + static constexpr bool less_than_equal12 = (data1 <= data2); + static constexpr bool less_than_equal23 = (data2 <= data3); + static constexpr bool less_than_equal21 = (data2 <= data1); + static constexpr bool less_than_equal32 = (data3 <= data2); + static constexpr bool less_than_equal11 = (data1 <= data1); + +#ifdef TEST_GREATER_THAN + CHECK_FALSE(less_than_equal12); + CHECK_FALSE(less_than_equal23); + CHECK_TRUE(less_than_equal21); + CHECK_TRUE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#else + CHECK_TRUE(less_than_equal12); + CHECK_TRUE(less_than_equal23); + CHECK_FALSE(less_than_equal21); + CHECK_FALSE(less_than_equal32); + CHECK_TRUE(less_than_equal11); +#endif + } + + //************************************************************************* + TEST(test_greater_than) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data1{values1}; + static constexpr Data data2{values2}; + static constexpr Data data3{values3}; + + static constexpr bool greater_than12 = (data1 > data2); + static constexpr bool greater_than23 = (data2 > data3); + static constexpr bool greater_than21 = (data2 > data1); + static constexpr bool greater_than32 = (data3 > data2); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than12); + CHECK_TRUE(greater_than23); + CHECK_FALSE(greater_than21); + CHECK_FALSE(greater_than32); +#else + CHECK_FALSE(greater_than12); + CHECK_FALSE(greater_than23); + CHECK_TRUE(greater_than21); + CHECK_TRUE(greater_than32); +#endif + } + + //************************************************************************* + TEST(test_greater_than_with_transparent_comparator) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr DataTransparentComparator data1{values1}; + static constexpr DataTransparentComparator data2{values2}; + static constexpr DataTransparentComparator data3{values3}; + + static constexpr bool greater_than12 = (data1 > data2); + static constexpr bool greater_than23 = (data2 > data3); + static constexpr bool greater_than21 = (data2 > data1); + static constexpr bool greater_than32 = (data3 > data2); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than12); + CHECK_TRUE(greater_than23); + CHECK_FALSE(greater_than21); + CHECK_FALSE(greater_than32); +#else + CHECK_FALSE(greater_than12); + CHECK_FALSE(greater_than23); + CHECK_TRUE(greater_than21); + CHECK_TRUE(greater_than32); +#endif + } + + //************************************************************************* + TEST(test_greater_than_equal) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr Data data1{values1}; + static constexpr Data data2{values2}; + static constexpr Data data3{values3}; + + static constexpr bool greater_than_equal12 = (data1 >= data2); + static constexpr bool greater_than_equal23 = (data2 >= data3); + static constexpr bool greater_than_equal21 = (data2 >= data1); + static constexpr bool greater_than_equal32 = (data3 >= data2); + static constexpr bool greater_than_equal11 = (data1 >= data1); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than_equal12); + CHECK_TRUE(greater_than_equal23); + CHECK_FALSE(greater_than_equal21); + CHECK_FALSE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#else + CHECK_FALSE(greater_than_equal12); + CHECK_FALSE(greater_than_equal23); + CHECK_TRUE(greater_than_equal21); + CHECK_TRUE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#endif + } + + //************************************************************************* + TEST(test_greater_than_equal_with_transparent_comparator) + { + static constexpr value_type values1[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('B'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values2[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('C'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr value_type values3[]{ value_type{Key('A'), 0 }, value_type{Key('B'), 1 }, value_type{Key('D'), 2 }, value_type{Key('D'), 3 }, value_type{Key('E'), 4 }, + value_type{Key('F'), 5 }, value_type{Key('G'), 6 }, value_type{Key('H'), 7 }, value_type{Key('I'), 8 }, value_type{Key('J'), 9 } }; + + static constexpr DataTransparentComparator data1{values1}; + static constexpr DataTransparentComparator data2{values2}; + static constexpr DataTransparentComparator data3{values3}; + + static constexpr bool greater_than_equal12 = (data1 >= data2); + static constexpr bool greater_than_equal23 = (data2 >= data3); + static constexpr bool greater_than_equal21 = (data2 >= data1); + static constexpr bool greater_than_equal32 = (data3 >= data2); + static constexpr bool greater_than_equal11 = (data1 >= data1); + +#ifdef TEST_GREATER_THAN + CHECK_TRUE(greater_than_equal12); + CHECK_TRUE(greater_than_equal23); + CHECK_FALSE(greater_than_equal21); + CHECK_FALSE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#else + CHECK_FALSE(greater_than_equal12); + CHECK_FALSE(greater_than_equal23); + CHECK_TRUE(greater_than_equal21); + CHECK_TRUE(greater_than_equal32); + CHECK_TRUE(greater_than_equal11); +#endif + } + }; +} diff --git a/test/vs2022/etl.vcxproj b/test/vs2022/etl.vcxproj index 41cfa582..fbb10c95 100644 --- a/test/vs2022/etl.vcxproj +++ b/test/vs2022/etl.vcxproj @@ -9274,8 +9274,12 @@ + + + + diff --git a/test/vs2022/etl.vcxproj.filters b/test/vs2022/etl.vcxproj.filters index 9874dd7e..4f9af8a2 100644 --- a/test/vs2022/etl.vcxproj.filters +++ b/test/vs2022/etl.vcxproj.filters @@ -1516,7 +1516,7 @@ ETL\Containers - UnitTest++\Header Files + ETL\Containers @@ -3611,6 +3611,18 @@ Tests\Containers + + Tests\Containers + + + Tests\Containers + + + Tests\Containers + + + Tests\Containers +