operator== work in progress, undocumented and untested.

[SVN r42106]
This commit is contained in:
Daniel James
2007-12-16 17:48:25 +00:00
parent 18d3eb6926
commit c918da0249
8 changed files with 359 additions and 9 deletions

View File

@@ -111,6 +111,7 @@ void container_test(X& r, T&)
(&a1)->~X();
X const a_const;
test::check_return_type<iterator>::equals(a.begin());
test::check_return_type<const_iterator>::equals(a_const.begin());
test::check_return_type<const_iterator>::equals(a.cbegin());
@@ -119,12 +120,13 @@ void container_test(X& r, T&)
test::check_return_type<const_iterator>::equals(a_const.end());
test::check_return_type<const_iterator>::equals(a.cend());
test::check_return_type<const_iterator>::equals(a_const.cend());
// No tests for ==, != since they're not required for unordered containers.
a.swap(b);
test::check_return_type<X>::equals_ref(r = a);
test::check_return_type<size_type>::equals(a.size());
test::check_return_type<size_type>::equals(a.max_size());
test::check_return_type<bool>::convertible(a.empty());
}
template <class X, class T>
void equality_test(X& r, T&)
{
X const a = r, b = r;
test::check_return_type<bool>::equals(a == b);
test::check_return_type<bool>::equals(a != b);
}

View File

@@ -13,7 +13,7 @@
#include "../objects/minimal.hpp"
#include "./compile_tests.hpp"
int main()
void container_tests()
{
typedef std::pair<test::minimal::assignable const,
test::minimal::copy_constructible> value_type;
@@ -40,6 +40,36 @@ int main()
test::minimal::allocator<value_type> > multimap;
container_test(multimap, value);
}
void equality_tests() {
typedef std::pair<test::minimal::assignable const,
test::minimal::copy_constructible_equality_comparable> value_type;
value_type value(
test::minimal::assignable::create(),
test::minimal::copy_constructible_equality_comparable::create());
boost::unordered_map<
test::minimal::assignable,
test::minimal::copy_constructible_equality_comparable,
test::minimal::hash<test::minimal::assignable>,
test::minimal::equal_to<test::minimal::assignable>,
test::minimal::allocator<value_type> > map;
equality_test(map, value);
boost::unordered_multimap<
test::minimal::assignable,
test::minimal::copy_constructible_equality_comparable,
test::minimal::hash<test::minimal::assignable>,
test::minimal::equal_to<test::minimal::assignable>,
test::minimal::allocator<value_type> > multimap;
equality_test(multimap, value);
}
int main() {
container_tests();
equality_tests();
return boost::report_errors();
}

View File

@@ -25,6 +25,7 @@ int main()
test::minimal::allocator<test::minimal::assignable> > set;
container_test(set, assignable);
equality_test(set, assignable);
std::cout<<"Test unordered_multiset.\n";
boost::unordered_multiset<
@@ -34,6 +35,7 @@ int main()
test::minimal::allocator<test::minimal::assignable> > multiset;
container_test(multiset, assignable);
equality_test(multiset, assignable);
return boost::report_errors();
}

View File

@@ -18,6 +18,7 @@ namespace test
namespace minimal
{
class copy_constructible;
class copy_constructible_equality_comparable;
class default_copy_constructible;
class assignable;
template <class T> class hash;
@@ -37,6 +38,25 @@ namespace minimal
copy_constructible() {}
};
class copy_constructible_equality_comparable
{
public:
static copy_constructible_equality_comparable create() { return copy_constructible_equality_comparable(); }
copy_constructible_equality_comparable(copy_constructible_equality_comparable const&) {}
~copy_constructible_equality_comparable() {}
private:
copy_constructible_equality_comparable& operator=(copy_constructible_equality_comparable const&);
copy_constructible_equality_comparable() {}
};
bool operator==(copy_constructible_equality_comparable, copy_constructible_equality_comparable) {
return true;
}
bool operator!=(copy_constructible_equality_comparable, copy_constructible_equality_comparable) {
return false;
}
class default_copy_constructible
{
public: