mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
contains() & transparent comparator for map, multimap, set and multiset
This commit is contained in:
parent
85fb83f0be
commit
4d48082f4f
@ -1382,6 +1382,7 @@ namespace etl
|
||||
return find(key) != end();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
template <typename K, typename = typename TKeyCompare::is_transparent>
|
||||
bool contains(const K& k) const
|
||||
{
|
||||
|
||||
@ -750,7 +750,7 @@ namespace etl
|
||||
friend class imultimap;
|
||||
friend class const_iterator;
|
||||
|
||||
iterator()
|
||||
iterator()
|
||||
: p_multimap(ETL_NULLPTR)
|
||||
, p_node(ETL_NULLPTR)
|
||||
{
|
||||
|
||||
@ -661,10 +661,12 @@ namespace etl
|
||||
{
|
||||
return compare(node1.value, node2.value);
|
||||
}
|
||||
|
||||
bool node_comp(const Data_Node& node, key_parameter_t key) const
|
||||
{
|
||||
return compare(node.value, key);
|
||||
}
|
||||
|
||||
bool node_comp(key_parameter_t key, const Data_Node& node) const
|
||||
{
|
||||
return compare(key, node.value);
|
||||
@ -678,7 +680,6 @@ namespace etl
|
||||
|
||||
template <typename K, typename = typename TCompare::is_transparent>
|
||||
bool node_comp(const K& key, const Data_Node& node) const
|
||||
|
||||
{
|
||||
return compare(key, node.value);
|
||||
}
|
||||
@ -1085,22 +1086,36 @@ namespace etl
|
||||
/// Returns two iterators with bounding (lower bound, upper bound) the key
|
||||
/// provided
|
||||
//*************************************************************************
|
||||
ETL_OR_STD::pair<iterator, iterator> equal_range(const_reference key)
|
||||
ETL_OR_STD::pair<iterator, iterator> equal_range(key_parameter_t key)
|
||||
{
|
||||
return ETL_OR_STD::make_pair<iterator, iterator>(
|
||||
iterator(*this, find_lower_node(root_node, key)),
|
||||
iterator(*this, find_upper_node(root_node, key)));
|
||||
return ETL_OR_STD::make_pair<iterator, iterator>(iterator(*this, find_lower_node(root_node, key)),
|
||||
iterator(*this, find_upper_node(root_node, key)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
template <typename K, typename = typename TCompare::is_transparent>
|
||||
ETL_OR_STD::pair<iterator, iterator> equal_range(const K& key)
|
||||
{
|
||||
return ETL_OR_STD::make_pair<iterator, iterator>(iterator(*this, find_lower_node(root_node, key)),
|
||||
iterator(*this, find_upper_node(root_node, key)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns two const iterators with bounding (lower bound, upper bound)
|
||||
/// the key provided.
|
||||
//*************************************************************************
|
||||
ETL_OR_STD::pair<const_iterator, const_iterator> equal_range(const_reference key) const
|
||||
ETL_OR_STD::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const
|
||||
{
|
||||
return ETL_OR_STD::make_pair<const_iterator, const_iterator>(
|
||||
const_iterator(*this, find_lower_node(root_node, key)),
|
||||
const_iterator(*this, find_upper_node(root_node, key)));
|
||||
return ETL_OR_STD::make_pair<const_iterator, const_iterator>(const_iterator(*this, find_lower_node(root_node, key)),
|
||||
const_iterator(*this, find_upper_node(root_node, key)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
template <typename K, typename = typename TCompare::is_transparent>
|
||||
ETL_OR_STD::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const
|
||||
{
|
||||
return ETL_OR_STD::make_pair<const_iterator, const_iterator>(const_iterator(*this, find_lower_node(root_node, key)),
|
||||
const_iterator(*this, find_upper_node(root_node, key)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1454,7 +1469,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Check if the set contains the key.
|
||||
//*************************************************************************
|
||||
bool contains(const TKey& key) const
|
||||
bool contains(key_parameter_t key) const
|
||||
{
|
||||
return find(key) != end();
|
||||
}
|
||||
|
||||
@ -956,22 +956,36 @@ namespace etl
|
||||
/// Returns two iterators with bounding (lower bound, upper bound) the
|
||||
/// value provided
|
||||
//*************************************************************************
|
||||
ETL_OR_STD::pair<iterator, iterator> equal_range(const_reference value)
|
||||
ETL_OR_STD::pair<iterator, iterator> equal_range(key_parameter_t key)
|
||||
{
|
||||
return ETL_OR_STD::make_pair<iterator, iterator>(
|
||||
iterator(*this, find_lower_node(root_node, value)),
|
||||
iterator(*this, find_upper_node(root_node, value)));
|
||||
return ETL_OR_STD::make_pair<iterator, iterator>(iterator(*this, find_lower_node(root_node, key)),
|
||||
iterator(*this, find_upper_node(root_node, key)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
template <typename K, typename = typename TCompare::is_transparent>
|
||||
ETL_OR_STD::pair<iterator, iterator> equal_range(const K& key)
|
||||
{
|
||||
return ETL_OR_STD::make_pair<iterator, iterator>(iterator(*this, find_lower_node(root_node, key)),
|
||||
iterator(*this, find_upper_node(root_node, key)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns two const iterators with bounding (lower bound, upper bound)
|
||||
/// the value provided.
|
||||
//*************************************************************************
|
||||
ETL_OR_STD::pair<const_iterator, const_iterator> equal_range(const_reference value) const
|
||||
ETL_OR_STD::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const
|
||||
{
|
||||
return ETL_OR_STD::make_pair<const_iterator, const_iterator>(
|
||||
const_iterator(*this, find_lower_node(root_node, value)),
|
||||
const_iterator(*this, find_upper_node(root_node, value)));
|
||||
return ETL_OR_STD::make_pair<const_iterator, const_iterator>(const_iterator(*this, find_lower_node(root_node, key)),
|
||||
const_iterator(*this, find_upper_node(root_node, key)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
template <typename K, typename = typename TCompare::is_transparent>
|
||||
ETL_OR_STD::pair<const_iterator, const_iterator> equal_range(const K& key) const
|
||||
{
|
||||
return ETL_OR_STD::make_pair<const_iterator, const_iterator>(const_iterator(*this, find_lower_node(root_node, key)),
|
||||
const_iterator(*this, find_upper_node(root_node, key)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -78,6 +78,26 @@ using Compare_Data_const_iterator = Compare_Data::const_iterator;
|
||||
|
||||
namespace
|
||||
{
|
||||
struct Key
|
||||
{
|
||||
Key(int k_)
|
||||
: k(k_)
|
||||
{
|
||||
}
|
||||
|
||||
int k;
|
||||
};
|
||||
|
||||
bool operator <(const Key& lhs, const int& rhs)
|
||||
{
|
||||
return (lhs.k < rhs);
|
||||
}
|
||||
|
||||
bool operator <(const int& lhs, const Key& rhs)
|
||||
{
|
||||
return (lhs < rhs.k);
|
||||
}
|
||||
|
||||
SUITE(test_multiset)
|
||||
{
|
||||
//*************************************************************************
|
||||
@ -632,18 +652,14 @@ namespace
|
||||
Data data(random_data.begin(), random_data.end());
|
||||
|
||||
// Test a number not available
|
||||
ETL_OR_STD::pair<Data::iterator, Data::iterator> data_result =
|
||||
data.equal_range(1);
|
||||
ETL_OR_STD::pair<Compare_Data::iterator, Compare_Data::iterator> compare_result =
|
||||
compare_data.equal_range(1);
|
||||
ETL_OR_STD::pair<Data::iterator, Data::iterator> data_result = data.equal_range(1);
|
||||
ETL_OR_STD::pair<Compare_Data::iterator, Compare_Data::iterator> compare_result = compare_data.equal_range(1);
|
||||
|
||||
// Check that both return the same return results
|
||||
CHECK_EQUAL(*compare_result.first, *data_result.first);
|
||||
CHECK_EQUAL(*compare_result.second, *data_result.second);
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
@ -655,18 +671,14 @@ namespace
|
||||
const Data data(initial_data.begin(), initial_data.end());
|
||||
|
||||
// Test a number with several of the same key
|
||||
ETL_OR_STD::pair<Data::const_iterator, Data::const_iterator> data_result =
|
||||
data.equal_range(2);
|
||||
ETL_OR_STD::pair<Compare_Data::const_iterator, Compare_Data::const_iterator> compare_result =
|
||||
compare_data.equal_range(2);
|
||||
ETL_OR_STD::pair<Data::const_iterator, Data::const_iterator> data_result = data.equal_range(2);
|
||||
ETL_OR_STD::pair<Compare_Data::const_iterator, Compare_Data::const_iterator> compare_result = compare_data.equal_range(2);
|
||||
|
||||
// Check that both return the same return results
|
||||
CHECK_EQUAL(*compare_result.first, *data_result.first);
|
||||
CHECK_EQUAL(*compare_result.second, *data_result.second);
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
@ -697,9 +709,41 @@ namespace
|
||||
// Check that both return the same return results
|
||||
CHECK_EQUAL(compare_count, data_count);
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_erase_value_using_transparent_comparator)
|
||||
{
|
||||
using CSet = std::multiset<int, std::less<int>>;
|
||||
CSet compare_data(initial_data.begin(), initial_data.end());
|
||||
|
||||
using ESet = etl::multiset<int, MAX_SIZE, std::less<>>;
|
||||
ESet data(initial_data.begin(), initial_data.end());
|
||||
|
||||
size_t compare_count = compare_data.erase(2);
|
||||
size_t data_count = data.erase(Key(2));
|
||||
|
||||
// Check that both return the same return results
|
||||
CHECK_EQUAL(compare_count, data_count);
|
||||
|
||||
// Erase another value
|
||||
compare_count = compare_data.erase(1);
|
||||
data_count = data.erase(1);
|
||||
|
||||
// Check that both return the same return results
|
||||
CHECK_EQUAL(compare_count, data_count);
|
||||
|
||||
// Erase another value
|
||||
compare_count = compare_data.erase(3);
|
||||
data_count = data.erase(3);
|
||||
|
||||
// Check that both return the same return results
|
||||
CHECK_EQUAL(compare_count, data_count);
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
@ -718,9 +762,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(*i_compare1, *i_data1);
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
@ -817,6 +859,24 @@ namespace
|
||||
CHECK_EQUAL(compare_data.count(99), data.count(99));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_count_using_transparent_comparator)
|
||||
{
|
||||
using CSet = std::multiset<int, std::less<int>>;
|
||||
const CSet compare_data(initial_data.begin(), initial_data.end());
|
||||
|
||||
using ESet = etl::multiset<int, MAX_SIZE, std::less<>>;
|
||||
const ESet data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CHECK_EQUAL(compare_data.count(-1), data.count(Key(-1)));
|
||||
CHECK_EQUAL(compare_data.count(0), data.count(Key(0)));
|
||||
CHECK_EQUAL(compare_data.count(1), data.count(Key(1)));
|
||||
CHECK_EQUAL(compare_data.count(2), data.count(Key(2)));
|
||||
CHECK_EQUAL(compare_data.count(3), data.count(Key(3)));
|
||||
CHECK_EQUAL(compare_data.count(4), data.count(Key(4)));
|
||||
CHECK_EQUAL(compare_data.count(99), data.count(Key(99)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_iterator)
|
||||
{
|
||||
@ -918,6 +978,54 @@ namespace
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_using_transparent_comparator)
|
||||
{
|
||||
using CSet = std::multiset<int, std::less<int>>;
|
||||
CSet compare_data(initial_data.begin(), initial_data.end());
|
||||
|
||||
using ESet = etl::multiset<int, MAX_SIZE, std::less<>>;
|
||||
ESet data(initial_data.begin(), initial_data.end());
|
||||
|
||||
ESet::iterator i_data = data.find(Key(0));
|
||||
CSet::iterator i_compare = compare_data.find(0);
|
||||
|
||||
// Check that both return successful return results
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_data = data.find(Key(1));
|
||||
i_compare = compare_data.find(1);
|
||||
|
||||
// Check that both return successful return results
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_data = data.find(Key(2));
|
||||
i_compare = compare_data.find(2);
|
||||
|
||||
// Check that both return successful return results
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_data = data.find(Key(3));
|
||||
i_compare = compare_data.find(3);
|
||||
|
||||
// Check that both return successful return results
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_data = data.find(Key(-1));
|
||||
i_compare = compare_data.find(-1);
|
||||
|
||||
// Check that both return successful return results
|
||||
CHECK(data.end() == i_data);
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
|
||||
i_data = data.find(Key(99));
|
||||
i_compare = compare_data.find(99);
|
||||
|
||||
// Check that both return successful return results
|
||||
CHECK(data.end() == i_data);
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_const)
|
||||
{
|
||||
@ -963,6 +1071,54 @@ namespace
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_const_using_transparent_comparator)
|
||||
{
|
||||
using CSet = std::multiset<int, std::less<int>>;
|
||||
CSet compare_data(initial_data.begin(), initial_data.end());
|
||||
|
||||
using ESet = etl::multiset<int, MAX_SIZE, std::less<>>;
|
||||
ESet data(initial_data.begin(), initial_data.end());
|
||||
|
||||
ESet::const_iterator i_data = data.find(Key(0));
|
||||
CSet::const_iterator i_compare = compare_data.find(0);
|
||||
|
||||
// Check that both return successful return results
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_data = data.find(Key(1));
|
||||
i_compare = compare_data.find(1);
|
||||
|
||||
// Check that both return successful return results
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_data = data.find(Key(2));
|
||||
i_compare = compare_data.find(2);
|
||||
|
||||
// Check that both return successful return results
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_data = data.find(Key(3));
|
||||
i_compare = compare_data.find(3);
|
||||
|
||||
// Check that both return successful return results
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_data = data.find(Key(-1));
|
||||
i_compare = compare_data.find(-1);
|
||||
|
||||
// Check that both return successful return results
|
||||
CHECK(data.end() == i_data);
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
|
||||
i_data = data.find(Key(99));
|
||||
i_compare = compare_data.find(99);
|
||||
|
||||
// Check that both return successful return results
|
||||
CHECK(data.end() == i_data);
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_equal)
|
||||
{
|
||||
@ -1022,6 +1178,30 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_lower_bound_using_transparent_comparator)
|
||||
{
|
||||
using CSet = std::multiset<int, std::less<int>>;
|
||||
CSet compare_data(initial_data.begin(), initial_data.end());
|
||||
|
||||
using ESet = etl::multiset<int, MAX_SIZE, std::less<>>;
|
||||
ESet data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CSet::iterator i_compare = compare_data.lower_bound(2);
|
||||
ESet::iterator i_data = data.lower_bound(Key(2));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.lower_bound(-1);
|
||||
i_data = data.lower_bound(Key(-1));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.lower_bound(99);
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
|
||||
i_data = data.lower_bound(Key(99));
|
||||
CHECK(data.end() == i_data);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_lower_bound_const)
|
||||
{
|
||||
@ -1055,6 +1235,30 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_lower_bound_const_using_transparent_comparator)
|
||||
{
|
||||
using CSet = std::multiset<int, std::less<int>>;
|
||||
CSet compare_data(initial_data.begin(), initial_data.end());
|
||||
|
||||
using ESet = etl::multiset<int, MAX_SIZE, std::less<>>;
|
||||
ESet data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CSet::const_iterator i_compare = compare_data.lower_bound(4);
|
||||
ESet::const_iterator i_data = data.lower_bound(Key(4));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.lower_bound(-1);
|
||||
i_data = data.lower_bound(Key(-1));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.lower_bound(99);
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
|
||||
i_data = data.lower_bound(Key(99));
|
||||
CHECK(data.end() == i_data);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_upper_bound)
|
||||
{
|
||||
@ -1088,10 +1292,34 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_upper_bound_using_transparent_comparator)
|
||||
{
|
||||
using CSet = std::multiset<int, std::less<int>>;
|
||||
CSet compare_data(initial_data.begin(), initial_data.end());
|
||||
|
||||
using ESet = etl::multiset<int, MAX_SIZE, std::less<>>;
|
||||
ESet data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CSet::iterator i_compare = compare_data.upper_bound(1);
|
||||
ESet::iterator i_data = data.upper_bound(Key(1));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.upper_bound(-1);
|
||||
i_data = data.upper_bound(Key(-1));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.upper_bound(99);
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
|
||||
i_data = data.upper_bound(Key(99));
|
||||
CHECK(data.end() == i_data);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_upper_bound_const)
|
||||
{
|
||||
Compare_Data compare_data(initial_data.begin(), initial_data.end());
|
||||
const Compare_Data compare_data(initial_data.begin(), initial_data.end());
|
||||
const Data data(initial_data.begin(), initial_data.end());
|
||||
|
||||
Compare_Data::const_iterator i_compare = compare_data.upper_bound(3);
|
||||
@ -1121,6 +1349,30 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_upper_bound_const_using_transparent_comparator)
|
||||
{
|
||||
using CSet = std::multiset<int, std::less<int>>;
|
||||
const CSet compare_data(initial_data.begin(), initial_data.end());
|
||||
|
||||
using ESet = etl::multiset<int, MAX_SIZE, std::less<>>;
|
||||
const ESet data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CSet::const_iterator i_compare = compare_data.upper_bound(3);
|
||||
ESet::const_iterator i_data = data.upper_bound(Key(3));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.upper_bound(-1);
|
||||
i_data = data.upper_bound(Key(-1));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.upper_bound(99);
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
|
||||
i_data = data.upper_bound(Key(99));
|
||||
CHECK(data.end() == i_data);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_key_compare)
|
||||
{
|
||||
@ -1140,6 +1392,21 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_key_compare_using_transparent_comparator)
|
||||
{
|
||||
using ESet = etl::multiset<int, MAX_SIZE, std::less<>>;
|
||||
const ESet data(initial_data.begin(), initial_data.end());
|
||||
|
||||
ESet::key_compare compare = data.key_comp();
|
||||
|
||||
int a(1);
|
||||
ESet::key_type b(2);
|
||||
|
||||
CHECK(compare(a, b));
|
||||
CHECK(!compare(b, a));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_value_compare)
|
||||
{
|
||||
@ -1218,6 +1485,68 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_compare_lower_upper_bound_using_transparent_comparator)
|
||||
{
|
||||
using CSet = std::multiset<int, std::less<int>>;
|
||||
CSet compare(initial_data.begin(), initial_data.end());
|
||||
|
||||
using ESet = etl::multiset<int, MAX_SIZE, std::less<>>;
|
||||
ESet data(initial_data.begin(), initial_data.end());
|
||||
|
||||
std::vector<int> tab(test_data.begin(), test_data.end());
|
||||
|
||||
//make sure both data and compare contain same elements
|
||||
std::vector<int> data_elements(data.begin(), data.end());
|
||||
std::vector<int> compare_data_elements(compare.begin(), compare.end());
|
||||
|
||||
CHECK(data_elements == compare_data_elements);
|
||||
CHECK_EQUAL(data_elements.size(), MAX_SIZE);
|
||||
|
||||
for (std::vector<int>::iterator it = tab.begin(); it != tab.end(); ++it)
|
||||
{
|
||||
int i = *it;
|
||||
|
||||
//lower_bound
|
||||
CHECK_EQUAL(compare.lower_bound(i) == compare.end(), data.lower_bound(i) == data.end());
|
||||
//if both end, or none
|
||||
if ((compare.lower_bound(i) == compare.end()) == (data.lower_bound(i) == data.end()))
|
||||
{
|
||||
//if both are not end
|
||||
if (compare.lower_bound(i) != compare.end())
|
||||
{
|
||||
CHECK((*compare.lower_bound(i)) == (*data.lower_bound(i)));
|
||||
}
|
||||
|
||||
ETL_OR_STD::pair<CSet::const_iterator, CSet::const_iterator> stlret = compare.equal_range(i);
|
||||
ETL_OR_STD::pair<ESet::const_iterator, ESet::const_iterator> etlret = data.equal_range(Key(i));
|
||||
|
||||
CHECK_EQUAL(stlret.first == compare.end(), etlret.first == data.end());
|
||||
if ((stlret.first != compare.end()) && (etlret.first != data.end()))
|
||||
{
|
||||
CHECK((*stlret.first) == (*etlret.first));
|
||||
}
|
||||
CHECK_EQUAL(stlret.second == compare.end(), etlret.second == data.end());
|
||||
if ((stlret.second != compare.end()) && (etlret.second != data.end()))
|
||||
{
|
||||
CHECK((*stlret.second) == (*etlret.second));
|
||||
}
|
||||
}
|
||||
|
||||
//upper_bound
|
||||
CHECK_EQUAL(compare.upper_bound(i) == compare.end(), data.upper_bound(i) == data.end());
|
||||
//if both end, or none
|
||||
if ((compare.upper_bound(i) == compare.end()) == (data.upper_bound(i) == data.end()))
|
||||
{
|
||||
//if both are not end
|
||||
if (compare.upper_bound(i) != compare.end())
|
||||
{
|
||||
CHECK((*compare.upper_bound(i)) == (*data.upper_bound(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_erase_bug)
|
||||
{
|
||||
@ -1304,5 +1633,28 @@ namespace
|
||||
CHECK_EQUAL("F", *itr);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_contains)
|
||||
{
|
||||
std::array<int, 6U> initial = { 1, 2, 3, 4, 5, 6 };
|
||||
etl::multiset<int, 6U, etl::less<>> data(initial.begin(), initial.end());
|
||||
|
||||
CHECK(data.contains(1));
|
||||
CHECK(!data.contains(99));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_contains_using_transparent_comparator)
|
||||
{
|
||||
std::array<int, 6U> initial = { 1, 2, 3, 4, 5, 6 };
|
||||
etl::multiset<int, 6U, etl::less<>> data(initial.begin(), initial.end());
|
||||
|
||||
CHECK(data.contains(1));
|
||||
CHECK(data.contains(Key(1)));
|
||||
|
||||
CHECK(!data.contains(99));
|
||||
CHECK(!data.contains(Key(99)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -77,6 +77,26 @@ using Compare_Data_const_iterator = Compare_Data::const_iterator;
|
||||
|
||||
namespace
|
||||
{
|
||||
struct Key
|
||||
{
|
||||
Key(int k_)
|
||||
: k(k_)
|
||||
{
|
||||
}
|
||||
|
||||
int k;
|
||||
};
|
||||
|
||||
bool operator <(const Key& lhs, const int& rhs)
|
||||
{
|
||||
return (lhs.k < rhs);
|
||||
}
|
||||
|
||||
bool operator <(const int& lhs, const Key& rhs)
|
||||
{
|
||||
return (lhs < rhs.k);
|
||||
}
|
||||
|
||||
SUITE(test_set)
|
||||
{
|
||||
//*************************************************************************
|
||||
@ -111,97 +131,32 @@ namespace
|
||||
{
|
||||
int n[] =
|
||||
{
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||
};
|
||||
|
||||
Data::value_type n2[] =
|
||||
{
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
||||
};
|
||||
|
||||
int n3[] =
|
||||
{
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||
};
|
||||
|
||||
int n4[] =
|
||||
{
|
||||
6,
|
||||
5,
|
||||
0,
|
||||
8,
|
||||
9,
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
7,
|
||||
4,
|
||||
6, 5, 0, 8, 9, 2, 1, 3, 7, 4,
|
||||
};
|
||||
|
||||
int n_even[] =
|
||||
{
|
||||
0,
|
||||
2,
|
||||
4,
|
||||
6,
|
||||
8,
|
||||
10,
|
||||
12,
|
||||
14,
|
||||
16,
|
||||
18,
|
||||
0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
|
||||
};
|
||||
|
||||
int n5[] =
|
||||
{
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
|
||||
} ;
|
||||
|
||||
initial_data.assign(std::begin(n), std::end(n));
|
||||
@ -655,9 +610,7 @@ namespace
|
||||
//CHECK_EQUAL(*data_result.first, *compare_result.first);
|
||||
|
||||
//// Check that elements in set are the same
|
||||
//bool isEqual = Check_Equal(data.begin(),
|
||||
// data.end(),
|
||||
// compare_data.begin());
|
||||
//bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin());
|
||||
//CHECK(isEqual);
|
||||
|
||||
//data.insert(2);
|
||||
@ -685,11 +638,9 @@ namespace
|
||||
Compare_Data compare_data(random_data.begin(), random_data.end());
|
||||
Data data(random_data.begin(), random_data.end());
|
||||
|
||||
ETL_OR_STD::pair<Data::iterator, Data::iterator> data_result =
|
||||
data.equal_range(2);
|
||||
ETL_OR_STD::pair<Data::iterator, Data::iterator> data_result = data.equal_range(2);
|
||||
Data::iterator data_lb = data.lower_bound(2);
|
||||
ETL_OR_STD::pair<Compare_Data::iterator, Compare_Data::iterator> compare_result =
|
||||
compare_data.equal_range(2);
|
||||
ETL_OR_STD::pair<Compare_Data::iterator, Compare_Data::iterator> compare_result = compare_data.equal_range(2);
|
||||
Compare_Data::iterator compare_data_lb = compare_data.lower_bound(2);
|
||||
|
||||
// Check that both return the same return results
|
||||
@ -735,9 +686,24 @@ namespace
|
||||
compare_data.erase(5);
|
||||
data.erase(5);
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_erase_value_using_transparent_comparator)
|
||||
{
|
||||
using CMap = std::set<int, std::less<int>>;
|
||||
using EMap = etl::set<int, MAX_SIZE, etl::less<>>;
|
||||
|
||||
CMap compare_data(initial_data.begin(), initial_data.end());
|
||||
EMap data(initial_data.begin(), initial_data.end());
|
||||
|
||||
compare_data.erase(5);
|
||||
data.erase(Key(5));
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
@ -865,6 +831,17 @@ namespace
|
||||
CHECK_EQUAL(data.count(11), size_t(0UL));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_count_using_transparent_comparator)
|
||||
{
|
||||
using EMap = etl::set<int, MAX_SIZE, etl::less<>>;
|
||||
const EMap data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CHECK_EQUAL(data.count(Key(3)), size_t(1UL));
|
||||
|
||||
CHECK_EQUAL(data.count(Key(11)), size_t(0UL));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_iterator)
|
||||
{
|
||||
@ -933,6 +910,19 @@ namespace
|
||||
CHECK(data.end() == it);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_using_transparent_comparator)
|
||||
{
|
||||
using EMap = etl::set<int, MAX_SIZE, etl::less<>>;
|
||||
EMap data(initial_data.begin(), initial_data.end());
|
||||
|
||||
EMap::iterator it = data.find(Key(3));
|
||||
CHECK_EQUAL(3, *it);
|
||||
|
||||
it = data.find(11);
|
||||
CHECK(data.end() == it);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_const)
|
||||
{
|
||||
@ -945,6 +935,19 @@ namespace
|
||||
CHECK(data.end() == it);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_const_using_transparent_comparator)
|
||||
{
|
||||
using EMap = etl::set<int, MAX_SIZE, etl::less<>>;
|
||||
const EMap data(initial_data.begin(), initial_data.end());
|
||||
|
||||
EMap::const_iterator it = data.find(Key(3));
|
||||
CHECK_EQUAL(3, *it);
|
||||
|
||||
it = data.find(11);
|
||||
CHECK(data.end() == it);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_equal)
|
||||
{
|
||||
@ -1004,6 +1007,30 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_lower_bound_using_transparent_comparator)
|
||||
{
|
||||
using CMap = std::set<int, std::less<int>>;
|
||||
using EMap = etl::set<int, MAX_SIZE, etl::less<>>;
|
||||
|
||||
CMap compare_data(initial_data.begin(), initial_data.end());
|
||||
EMap data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CMap::iterator i_compare = compare_data.lower_bound(8);
|
||||
EMap::iterator i_data = data.lower_bound(Key(8));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.lower_bound(-1);
|
||||
i_data = data.lower_bound(Key(-1));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.lower_bound(11);
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
|
||||
i_data = data.lower_bound(Key(11));
|
||||
CHECK(data.end() == i_data);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_lower_bound_const)
|
||||
{
|
||||
@ -1037,6 +1064,30 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_lower_bound_const_using_transparent_comparator)
|
||||
{
|
||||
using CMap = std::set<int, std::less<int>>;
|
||||
using EMap = etl::set<int, MAX_SIZE, etl::less<>>;
|
||||
|
||||
const CMap compare_data(initial_data.begin(), initial_data.end());
|
||||
const EMap data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CMap::const_iterator i_compare = compare_data.lower_bound(4);
|
||||
EMap::const_iterator i_data = data.lower_bound(Key(4));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.lower_bound(-1);
|
||||
i_data = data.lower_bound(-1);
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.lower_bound(11);
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
|
||||
i_data = data.lower_bound(11);
|
||||
CHECK(data.end() == i_data);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_upper_bound)
|
||||
{
|
||||
@ -1070,6 +1121,30 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_upper_bound_using_transparent_comparator)
|
||||
{
|
||||
using CMap = std::set<int, std::less<int>>;
|
||||
using EMap = etl::set<int, MAX_SIZE, etl::less<>>;
|
||||
|
||||
CMap compare_data(initial_data.begin(), initial_data.end());
|
||||
EMap data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CMap::iterator i_compare = compare_data.upper_bound(2);
|
||||
EMap::iterator i_data = data.upper_bound(Key(2));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.upper_bound(-1);
|
||||
i_data = data.upper_bound(-1);
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.upper_bound(11);
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
|
||||
i_data = data.upper_bound(11);
|
||||
CHECK(data.end() == i_data);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_upper_bound_const)
|
||||
{
|
||||
@ -1103,6 +1178,30 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_upper_bound_const_using_transparent_comparator)
|
||||
{
|
||||
using CMap = std::set<int, std::less<int>>;
|
||||
using EMap = etl::set<int, MAX_SIZE, etl::less<>>;
|
||||
|
||||
CMap compare_data(initial_data.begin(), initial_data.end());
|
||||
EMap data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CMap::const_iterator i_compare = compare_data.upper_bound(7);
|
||||
EMap::const_iterator i_data = data.upper_bound(Key(7));
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.upper_bound(-1);
|
||||
i_data = data.upper_bound(-1);
|
||||
CHECK_EQUAL(*i_compare, *i_data);
|
||||
|
||||
i_compare = compare_data.upper_bound(11);
|
||||
CHECK(compare_data.end() == i_compare);
|
||||
|
||||
i_data = data.upper_bound(11);
|
||||
CHECK(data.end() == i_data);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_key_compare)
|
||||
{
|
||||
@ -1122,6 +1221,21 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_key_compare_using_transparent_comparator)
|
||||
{
|
||||
using EMap = etl::set<int, MAX_SIZE, etl::less<>>;
|
||||
const EMap data(initial_data.begin(), initial_data.end());
|
||||
|
||||
EMap::key_compare compare = data.key_comp();
|
||||
|
||||
int a(1);
|
||||
Key b(2);
|
||||
|
||||
CHECK(compare(a, b));
|
||||
CHECK(!compare(b, a));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_value_compare)
|
||||
{
|
||||
@ -1162,6 +1276,7 @@ namespace
|
||||
|
||||
//lower_bound
|
||||
CHECK_EQUAL(compare.lower_bound(i) == compare.end(), data.lower_bound(i) == data.end());
|
||||
|
||||
//if both end, or none
|
||||
if((compare.lower_bound(i) == compare.end()) == (data.lower_bound(i) == data.end()))
|
||||
{
|
||||
@ -1175,11 +1290,14 @@ namespace
|
||||
ETL_OR_STD::pair<Data::const_iterator, Data::const_iterator> etlret = data.equal_range(i);
|
||||
|
||||
CHECK_EQUAL(stlret.first == compare.end(), etlret.first == data.end());
|
||||
|
||||
if((stlret.first != compare.end()) && (etlret.first != data.end()))
|
||||
{
|
||||
CHECK_EQUAL(*stlret.first, *etlret.first);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(stlret.second == compare.end(), etlret.second == data.end());
|
||||
|
||||
if((stlret.second != compare.end()) && (etlret.second != data.end()))
|
||||
{
|
||||
CHECK_EQUAL(*stlret.second, *etlret.second);
|
||||
@ -1188,6 +1306,7 @@ namespace
|
||||
|
||||
//upper_bound
|
||||
CHECK_EQUAL(compare.upper_bound(i) == compare.end(), data.upper_bound(i) == data.end());
|
||||
|
||||
//if both end, or none
|
||||
if((compare.upper_bound(i) == compare.end()) == (data.upper_bound(i) == data.end()))
|
||||
{
|
||||
@ -1200,6 +1319,73 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_compare_lower_upper_bound_using_transparent_comparator)
|
||||
{
|
||||
using CMap = std::set<int, std::less<int>>;
|
||||
using EMap = etl::set<int, MAX_SIZE, etl::less<>>;
|
||||
|
||||
CMap compare(initial_data.begin(), initial_data.end());
|
||||
EMap data(initial_data.begin(), initial_data.end());
|
||||
|
||||
std::vector<int> tab(test_data.begin(), test_data.end());
|
||||
|
||||
//make sure both data and compare contain same elements
|
||||
std::vector<int> data_elements(data.begin(), data.end());
|
||||
std::vector<int> compare_data_elements(compare.begin(), compare.end());
|
||||
|
||||
CHECK(data_elements == compare_data_elements);
|
||||
CHECK_EQUAL(data_elements.size(), MAX_SIZE);
|
||||
|
||||
for (std::vector<int>::iterator it = tab.begin(); it != tab.end(); ++it)
|
||||
{
|
||||
int i = *it;
|
||||
|
||||
//lower_bound
|
||||
CHECK_EQUAL(compare.lower_bound(i) == compare.end(), data.lower_bound(i) == data.end());
|
||||
|
||||
//if both end, or none
|
||||
if ((compare.lower_bound(i) == compare.end()) == (data.lower_bound(i) == data.end()))
|
||||
{
|
||||
//if both are not end
|
||||
if (compare.lower_bound(i) != compare.end())
|
||||
{
|
||||
CHECK_EQUAL(*compare.lower_bound(i), *data.lower_bound(i));
|
||||
}
|
||||
|
||||
ETL_OR_STD::pair<CMap::const_iterator, CMap::const_iterator> stlret = compare.equal_range(i);
|
||||
ETL_OR_STD::pair<EMap::const_iterator, EMap::const_iterator> etlret = data.equal_range(Key(i));
|
||||
|
||||
CHECK_EQUAL(stlret.first == compare.end(), etlret.first == data.end());
|
||||
|
||||
if ((stlret.first != compare.end()) && (etlret.first != data.end()))
|
||||
{
|
||||
CHECK_EQUAL(*stlret.first, *etlret.first);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(stlret.second == compare.end(), etlret.second == data.end());
|
||||
|
||||
if ((stlret.second != compare.end()) && (etlret.second != data.end()))
|
||||
{
|
||||
CHECK_EQUAL(*stlret.second, *etlret.second);
|
||||
}
|
||||
}
|
||||
|
||||
//upper_bound
|
||||
CHECK_EQUAL(compare.upper_bound(i) == compare.end(), data.upper_bound(i) == data.end());
|
||||
|
||||
//if both end, or none
|
||||
if ((compare.upper_bound(i) == compare.end()) == (data.upper_bound(i) == data.end()))
|
||||
{
|
||||
//if both are not end
|
||||
if (compare.upper_bound(i) != compare.end())
|
||||
{
|
||||
CHECK_EQUAL(*compare.upper_bound(i), *data.upper_bound(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST && !defined(ETL_TEMPLATE_DEDUCTION_GUIDE_TESTS_DISABLED)
|
||||
TEST(test_set_template_deduction)
|
||||
@ -1251,5 +1437,28 @@ namespace
|
||||
CHECK_EQUAL("F", *itr);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_contains)
|
||||
{
|
||||
std::array<int, 6U> initial = { 1, 2, 3, 4, 5, 6 };
|
||||
etl::set<int, 6U, etl::less<>> data(initial.begin(), initial.end());
|
||||
|
||||
CHECK(data.contains(1));
|
||||
CHECK(!data.contains(99));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_contains_using_transparent_comparator)
|
||||
{
|
||||
std::array<int, 6U> initial = { 1, 2, 3, 4, 5, 6 };
|
||||
etl::set<int, 6U, etl::less<>> data(initial.begin(), initial.end());
|
||||
|
||||
CHECK(data.contains(1));
|
||||
CHECK(data.contains(Key(1)));
|
||||
|
||||
CHECK(!data.contains(99));
|
||||
CHECK(!data.contains(Key(99)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user