forked from boostorg/unordered
Reformat with clang-format
This commit is contained in:
@@ -14,23 +14,25 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace insert_stable
|
||||
namespace insert_stable {
|
||||
struct member
|
||||
{
|
||||
struct member {
|
||||
int tag1_;
|
||||
int tag2_;
|
||||
|
||||
member() : tag1_(0), tag2_(0) {}
|
||||
member(int t1, int t2) : tag1_(t1), tag2_(t2) {}
|
||||
|
||||
friend bool operator==(member const& x, member const& y) {
|
||||
return x.tag1_ == y.tag1_;
|
||||
}
|
||||
|
||||
friend bool operator!=(member const& x, member const& y) {
|
||||
return x.tag1_ != y.tag1_;
|
||||
}
|
||||
};
|
||||
int tag1_;
|
||||
int tag2_;
|
||||
|
||||
member() : tag1_(0), tag2_(0) {}
|
||||
member(int t1, int t2) : tag1_(t1), tag2_(t2) {}
|
||||
|
||||
friend bool operator==(member const& x, member const& y)
|
||||
{
|
||||
return x.tag1_ == y.tag1_;
|
||||
}
|
||||
|
||||
friend bool operator!=(member const& x, member const& y)
|
||||
{
|
||||
return x.tag1_ != y.tag1_;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
@@ -39,51 +41,72 @@ namespace boost
|
||||
namespace insert_stable
|
||||
#endif
|
||||
{
|
||||
std::size_t hash_value(insert_stable::member const& x) {
|
||||
return static_cast<std::size_t>(x.tag1_);
|
||||
}
|
||||
std::size_t hash_value(insert_stable::member const& x)
|
||||
{
|
||||
return static_cast<std::size_t>(x.tag1_);
|
||||
}
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST(stable_insert_test1) {
|
||||
UNORDERED_AUTO_TEST(stable_insert_test1)
|
||||
{
|
||||
boost::unordered_multiset<insert_stable::member> x;
|
||||
|
||||
x.insert(insert_stable::member(1,1));
|
||||
x.insert(insert_stable::member(1,2));
|
||||
x.insert(insert_stable::member(1,3));
|
||||
x.insert(insert_stable::member(1, 1));
|
||||
x.insert(insert_stable::member(1, 2));
|
||||
x.insert(insert_stable::member(1, 3));
|
||||
|
||||
BOOST_TEST(x.count(insert_stable::member(1,4)) == 3);
|
||||
BOOST_TEST(x.count(insert_stable::member(1, 4)) == 3);
|
||||
|
||||
boost::unordered_multiset<insert_stable::member>::const_iterator
|
||||
it = x.begin(), end = x.end();
|
||||
it = x.begin(),
|
||||
end = x.end();
|
||||
BOOST_TEST(it != end);
|
||||
if(it != end) { BOOST_TEST(it->tag2_ == 1); ++it; }
|
||||
if (it != end) {
|
||||
BOOST_TEST(it->tag2_ == 1);
|
||||
++it;
|
||||
}
|
||||
BOOST_TEST(it != end);
|
||||
if(it != end) { BOOST_TEST(it->tag2_ == 2); ++it; }
|
||||
if (it != end) {
|
||||
BOOST_TEST(it->tag2_ == 2);
|
||||
++it;
|
||||
}
|
||||
BOOST_TEST(it != end);
|
||||
if(it != end) { BOOST_TEST(it->tag2_ == 3); ++it; }
|
||||
if (it != end) {
|
||||
BOOST_TEST(it->tag2_ == 3);
|
||||
++it;
|
||||
}
|
||||
BOOST_TEST(it == end);
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST(stable_insert_test2) {
|
||||
UNORDERED_AUTO_TEST(stable_insert_test2)
|
||||
{
|
||||
boost::unordered_multimap<insert_stable::member, int> x;
|
||||
typedef
|
||||
boost::unordered_multimap<insert_stable::member, int>::const_iterator
|
||||
iterator;
|
||||
typedef boost::unordered_multimap<insert_stable::member,
|
||||
int>::const_iterator iterator;
|
||||
|
||||
iterator it = x.emplace(insert_stable::member(1,1), 1);
|
||||
it = x.emplace(insert_stable::member(1,2), 2);
|
||||
it = x.emplace(insert_stable::member(1,3), 3);
|
||||
iterator it = x.emplace(insert_stable::member(1, 1), 1);
|
||||
it = x.emplace(insert_stable::member(1, 2), 2);
|
||||
it = x.emplace(insert_stable::member(1, 3), 3);
|
||||
|
||||
BOOST_TEST(x.count(insert_stable::member(1,4)) == 3);
|
||||
BOOST_TEST(x.count(insert_stable::member(1, 4)) == 3);
|
||||
|
||||
it = x.begin();
|
||||
iterator end = x.end();
|
||||
BOOST_TEST(it != end);
|
||||
if(it != end) { BOOST_TEST(it->first.tag2_ == 1 && it->second == 1); ++it; }
|
||||
if (it != end) {
|
||||
BOOST_TEST(it->first.tag2_ == 1 && it->second == 1);
|
||||
++it;
|
||||
}
|
||||
BOOST_TEST(it != end);
|
||||
if(it != end) { BOOST_TEST(it->first.tag2_ == 2 && it->second == 2); ++it; }
|
||||
if (it != end) {
|
||||
BOOST_TEST(it->first.tag2_ == 2 && it->second == 2);
|
||||
++it;
|
||||
}
|
||||
BOOST_TEST(it != end);
|
||||
if(it != end) { BOOST_TEST(it->first.tag2_ == 3 && it->second == 3); ++it; }
|
||||
if (it != end) {
|
||||
BOOST_TEST(it->first.tag2_ == 3 && it->second == 3);
|
||||
++it;
|
||||
}
|
||||
BOOST_TEST(it == end);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user