Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2008-04-05 09:37:04


Author: danieljames
Date: 2008-04-05 09:37:03 EDT (Sat, 05 Apr 2008)
New Revision: 44053
URL: http://svn.boost.org/trac/boost/changeset/44053

Log:
Add equality operators for the allocator, and change the compile tests so that they run tests with the default allocator and function objects - so that they catch things like this.
Text files modified:
   branches/unordered/dev/boost/unordered/detail/allocator.hpp | 12 ++++++++++++
   branches/unordered/dev/libs/unordered/test/unordered/compile_map.cpp | 14 ++++++++++++++
   branches/unordered/dev/libs/unordered/test/unordered/compile_set.cpp | 10 ++++++++++
   branches/unordered/dev/libs/unordered/test/unordered/compile_tests.hpp | 4 ++--
   4 files changed, 38 insertions(+), 2 deletions(-)

Modified: branches/unordered/dev/boost/unordered/detail/allocator.hpp
==============================================================================
--- branches/unordered/dev/boost/unordered/detail/allocator.hpp (original)
+++ branches/unordered/dev/boost/unordered/detail/allocator.hpp 2008-04-05 09:37:03 EDT (Sat, 05 Apr 2008)
@@ -95,6 +95,18 @@
             p->~T();
         }
     };
+
+ template <class T>
+ bool operator==(allocator<T> const&, allocator<T> const&)
+ {
+ return true;
+ }
+
+ template <class T>
+ bool operator!=(allocator<T> const&, allocator<T> const&)
+ {
+ return false;
+ }
 }
 }
 

Modified: branches/unordered/dev/libs/unordered/test/unordered/compile_map.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/compile_map.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/compile_map.cpp 2008-04-05 09:37:03 EDT (Sat, 05 Apr 2008)
@@ -22,6 +22,9 @@
             test::minimal::copy_constructible::create());
 
     std::cout<<"Test unordered_map.\n";
+
+ boost::unordered_map<int, int> int_map;
+
     boost::unordered_map<
         test::minimal::assignable,
         test::minimal::copy_constructible,
@@ -29,9 +32,13 @@
         test::minimal::equal_to<test::minimal::assignable>,
         test::minimal::allocator<value_type> > map;
 
+ container_test(int_map, std::pair<int const, int>(0, 0));
     container_test(map, value);
 
     std::cout<<"Test unordered_multimap.\n";
+
+ boost::unordered_multimap<int, int> int_multimap;
+
     boost::unordered_multimap<
         test::minimal::assignable,
         test::minimal::copy_constructible,
@@ -39,6 +46,7 @@
         test::minimal::equal_to<test::minimal::assignable>,
         test::minimal::allocator<value_type> > multimap;
 
+ container_test(int_multimap, std::pair<int const, int>(0, 0));
     container_test(multimap, value);
 }
 
@@ -49,6 +57,8 @@
             test::minimal::assignable::create(),
             test::minimal::copy_constructible_equality_comparable::create());
 
+ boost::unordered_map<int, int> int_map;
+
     boost::unordered_map<
         test::minimal::assignable,
         test::minimal::copy_constructible_equality_comparable,
@@ -56,8 +66,11 @@
         test::minimal::equal_to<test::minimal::assignable>,
         test::minimal::allocator<value_type> > map;
 
+ equality_test(int_map, std::pair<int const, int>(0, 0));
     equality_test(map, value);
 
+ boost::unordered_multimap<int, int> int_multimap;
+
     boost::unordered_multimap<
         test::minimal::assignable,
         test::minimal::copy_constructible_equality_comparable,
@@ -65,6 +78,7 @@
         test::minimal::equal_to<test::minimal::assignable>,
         test::minimal::allocator<value_type> > multimap;
 
+ equality_test(int_multimap, std::pair<int const, int>(0, 0));
     equality_test(multimap, value);
 }
 

Modified: branches/unordered/dev/libs/unordered/test/unordered/compile_set.cpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/compile_set.cpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/compile_set.cpp 2008-04-05 09:37:03 EDT (Sat, 05 Apr 2008)
@@ -18,21 +18,25 @@
     test::minimal::assignable assignable = test::minimal::assignable::create();
 
     std::cout<<"Test unordered_set.\n";
+ boost::unordered_set<int> int_set;
     boost::unordered_set<
         test::minimal::assignable,
         test::minimal::hash<test::minimal::assignable>,
         test::minimal::equal_to<test::minimal::assignable>,
         test::minimal::allocator<test::minimal::assignable> > set;
 
+ container_test(int_set, 0);
     container_test(set, assignable);
 
     std::cout<<"Test unordered_multiset.\n";
+ boost::unordered_multiset<int> int_multiset;
     boost::unordered_multiset<
         test::minimal::assignable,
         test::minimal::hash<test::minimal::assignable>,
         test::minimal::equal_to<test::minimal::assignable>,
         test::minimal::allocator<test::minimal::assignable> > multiset;
 
+ container_test(int_multiset, 0);
     container_test(multiset, assignable);
 }
 
@@ -43,20 +47,26 @@
             test::minimal::assignable::create(),
             test::minimal::copy_constructible::create());
 
+ boost::unordered_set<int> int_set;
+
     boost::unordered_set<
         test::minimal::assignable,
         test::minimal::hash<test::minimal::assignable>,
         test::minimal::equal_to<test::minimal::assignable>,
         test::minimal::allocator<value_type> > set;
 
+ equality_test(int_set, value);
     equality_test(set, value);
 
+ boost::unordered_multiset<int> int_multiset;
+
     boost::unordered_multiset<
         test::minimal::assignable,
         test::minimal::hash<test::minimal::assignable>,
         test::minimal::equal_to<test::minimal::assignable>,
         test::minimal::allocator<value_type> > multiset;
 
+ equality_test(int_multiset, value);
     equality_test(multiset, value);
 }
 

Modified: branches/unordered/dev/libs/unordered/test/unordered/compile_tests.hpp
==============================================================================
--- branches/unordered/dev/libs/unordered/test/unordered/compile_tests.hpp (original)
+++ branches/unordered/dev/libs/unordered/test/unordered/compile_tests.hpp 2008-04-05 09:37:03 EDT (Sat, 05 Apr 2008)
@@ -27,7 +27,7 @@
 template <class T> void sink(T const&) {}
 
 template <class X, class T>
-void container_test(X& r, T&)
+void container_test(X& r, T const&)
 {
     typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
     typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
@@ -145,7 +145,7 @@
 }
 
 template <class X, class T>
-void equality_test(X& r, T&)
+void equality_test(X& r, T const&)
 {
     X const a = r, b = r;
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk