Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2008-06-21 18:02:16


Author: danieljames
Date: 2008-06-21 18:02:15 EDT (Sat, 21 Jun 2008)
New Revision: 46594
URL: http://svn.boost.org/trac/boost/changeset/46594

Log:
Merge inspect fixes for the unordered library.

Merged revisions 46470-46592 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk

................
  r46589 | danieljames | 2008-06-21 21:37:42 +0100 (Sat, 21 Jun 2008) | 2 lines
  
  Fix some inspect errors (tabs and missing copyright/license).
................
  r46591 | danieljames | 2008-06-21 21:47:51 +0100 (Sat, 21 Jun 2008) | 1 line
  
  Move memory.hpp into the helpers subdirectory.
................
  r46592 | danieljames | 2008-06-21 22:08:53 +0100 (Sat, 21 Jun 2008) | 1 line
  
  Prevent inspect errors for unnamed namespaces in some of the test header files.
................

Added:
   trunk/libs/unordered/test/helpers/memory.hpp
      - copied unchanged from r46592, /branches/unordered/trunk/libs/unordered/test/helpers/memory.hpp
Removed:
   trunk/libs/unordered/test/objects/memory.hpp
Properties modified:
   trunk/ (props changed)
Text files modified:
   trunk/libs/unordered/doc/bibliography.xml | 5 +
   trunk/libs/unordered/examples/hash_functions/fnv-1.hpp | 7 +
   trunk/libs/unordered/test/helpers/count.hpp | 5 +
   trunk/libs/unordered/test/helpers/equivalent.hpp | 5 +
   trunk/libs/unordered/test/objects/exception.hpp | 2
   trunk/libs/unordered/test/objects/test.hpp | 7 +
   trunk/libs/unordered/test/unordered/equality_tests.cpp | 186 ++++++++++++++++++++--------------------
   7 files changed, 121 insertions(+), 96 deletions(-)

Modified: trunk/libs/unordered/doc/bibliography.xml
==============================================================================
--- trunk/libs/unordered/doc/bibliography.xml (original)
+++ trunk/libs/unordered/doc/bibliography.xml 2008-06-21 18:02:15 EDT (Sat, 21 Jun 2008)
@@ -1,3 +1,8 @@
+<!--
+Copyright Daniel James 2008
+Distributed under the Boost Software License, Version 1.0. (See accompanying
+file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+-->
 <section id="unordered.bibliography">
 <title>Bibliography</title>
 <bibliography>

Modified: trunk/libs/unordered/examples/hash_functions/fnv-1.hpp
==============================================================================
--- trunk/libs/unordered/examples/hash_functions/fnv-1.hpp (original)
+++ trunk/libs/unordered/examples/hash_functions/fnv-1.hpp 2008-06-21 18:02:15 EDT (Sat, 21 Jun 2008)
@@ -1,4 +1,9 @@
-// See: http://www.isthe.com/chongo/tech/comp/fnv/
+
+// Copyright 2008 Daniel James.
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// Algorithm from: http://www.isthe.com/chongo/tech/comp/fnv/
 
 #include <string>
 

Modified: trunk/libs/unordered/test/helpers/count.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/count.hpp (original)
+++ trunk/libs/unordered/test/helpers/count.hpp 2008-06-21 18:02:15 EDT (Sat, 21 Jun 2008)
@@ -53,6 +53,11 @@
     struct globally_counted_object
         : counted_object<globally_counted_object> {};
 
+ // This won't be a problem as I'm only using a single compile unit
+ // in each test (this is actually require by the minimal test
+ // framework).
+ //
+ // boostinspect:nounnamed
     namespace {
         object_count& global_object_count = globally_counted_object::count_;
     }

Modified: trunk/libs/unordered/test/helpers/equivalent.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/equivalent.hpp (original)
+++ trunk/libs/unordered/test/helpers/equivalent.hpp 2008-06-21 18:02:15 EDT (Sat, 21 Jun 2008)
@@ -44,6 +44,11 @@
         }
     };
 
+ // This won't be a problem as I'm only using a single compile unit
+ // in each test (this is actually require by the minimal test
+ // framework).
+ //
+ // boostinspect:nounnamed
     namespace {
         equivalent_type equivalent;
     }

Modified: trunk/libs/unordered/test/objects/exception.hpp
==============================================================================
--- trunk/libs/unordered/test/objects/exception.hpp (original)
+++ trunk/libs/unordered/test/objects/exception.hpp 2008-06-21 18:02:15 EDT (Sat, 21 Jun 2008)
@@ -14,7 +14,7 @@
 #include <new>
 #include "../helpers/fwd.hpp"
 #include "../helpers/allocator.hpp"
-#include "./memory.hpp"
+#include "../helpers/memory.hpp"
 
 namespace test
 {

Deleted: trunk/libs/unordered/test/objects/memory.hpp
==============================================================================
--- trunk/libs/unordered/test/objects/memory.hpp 2008-06-21 18:02:15 EDT (Sat, 21 Jun 2008)
+++ (empty file)
@@ -1,170 +0,0 @@
-
-// Copyright 2006-2008 Daniel James.
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#if !defined(BOOST_UNORDERED_TEST_MEMORY_HEADER)
-#define BOOST_UNORDERED_TEST_MEMORY_HEADER
-
-#include <memory>
-#include <map>
-#include <boost/mpl/apply.hpp>
-#include <boost/assert.hpp>
-#include <boost/unordered/detail/allocator_helpers.hpp>
-#include <boost/mpl/aux_/config/eti.hpp>
-#include "../helpers/test.hpp"
-
-namespace test
-{
- namespace detail
- {
- // This annoymous namespace won't cause ODR violations as I won't
- // be linking multiple translation units together. I'll probably
- // move this into a cpp file before a full release, but for now it's
- // the most convenient way.
-
- struct memory_area {
- void const* start;
- void const* end;
-
- memory_area(void const* s, void const* e)
- : start(s), end(e)
- {
- BOOST_ASSERT(start != end);
- }
- };
-
- struct memory_track {
- explicit memory_track(int tag = -1) :
- constructed_(0),
- tag_(tag) {}
-
- int constructed_;
- int tag_;
- };
-
- // This is a bit dodgy as it defines overlapping
- // areas as 'equal', so this isn't a total ordering.
- // But it is for non-overlapping memory regions - which
- // is what'll be stored.
- //
- // All searches will be for areas entirely contained by
- // a member of the set - so it should find the area that contains
- // the region that is searched for.
-
- struct memory_area_compare {
- bool operator()(memory_area const& x, memory_area const& y) const {
- return x.end <= y.start;
- }
- };
-
- template <class Alloc>
- struct allocator_memory_type_gen {
- typedef std::map<memory_area, memory_track, memory_area_compare,
- Alloc> type;
- };
-
-#if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
- template <>
- struct allocator_memory_type_gen<int> {
- typedef std::map<memory_area, memory_track, memory_area_compare> type;
- };
-#endif
-
- template <class Alloc = std::allocator<int> >
- struct memory_tracker {
- typedef BOOST_DEDUCED_TYPENAME
- boost::unordered_detail::rebind_wrap<Alloc,
- std::pair<memory_area const, memory_track> >::type
- allocator_type;
-
- typedef BOOST_DEDUCED_TYPENAME allocator_memory_type_gen<allocator_type>::type
- allocated_memory_type;
-
- allocated_memory_type allocated_memory;
- unsigned int count_allocators;
- unsigned int count_allocations;
- unsigned int count_constructions;
-
- memory_tracker() :
- count_allocators(0), count_allocations(0),
- count_constructions(0)
- {}
-
- void allocator_ref()
- {
- if(count_allocators == 0) {
- count_allocations = 0;
- count_constructions = 0;
- allocated_memory.clear();
- }
- ++count_allocators;
- }
-
- void allocator_unref()
- {
- BOOST_CHECK(count_allocators > 0);
- if(count_allocators > 0) {
- --count_allocators;
- if(count_allocators == 0) {
- bool no_allocations_left = (count_allocations == 0);
- bool no_constructions_left = (count_constructions == 0);
- bool allocated_memory_empty = allocated_memory.empty();
-
- // Clearing the data before the checks terminate the tests.
- count_allocations = 0;
- count_constructions = 0;
- allocated_memory.clear();
-
- BOOST_CHECK(no_allocations_left);
- BOOST_CHECK(no_constructions_left);
- BOOST_CHECK(allocated_memory_empty);
- }
- }
- }
-
- void track_allocate(void *ptr, std::size_t n, std::size_t size, int tag)
- {
- if(n == 0) {
- BOOST_ERROR("Allocating 0 length array.");
- }
- else {
- ++count_allocations;
- allocated_memory.insert(
- std::pair<memory_area const, memory_track>(
- memory_area(ptr, (char*) ptr + n * size),
- memory_track(tag)));
- }
- }
-
- void track_deallocate(void* ptr, std::size_t n, std::size_t size, int tag)
- {
- BOOST_DEDUCED_TYPENAME allocated_memory_type::iterator pos
- = allocated_memory.find(memory_area(ptr, (char*) ptr + n * size));
- if(pos == allocated_memory.end()) {
- BOOST_ERROR("Deallocating unknown pointer.");
- } else {
- BOOST_CHECK(pos->first.start == ptr);
- BOOST_CHECK(pos->first.end == (char*) ptr + n * size);
- BOOST_CHECK(pos->second.tag_ == tag);
- allocated_memory.erase(pos);
- }
- BOOST_CHECK(count_allocations > 0);
- if(count_allocations > 0) --count_allocations;
- }
-
- void track_construct(void* /*ptr*/, std::size_t /*size*/, int /*tag*/)
- {
- ++count_constructions;
- }
-
- void track_destroy(void* /*ptr*/, std::size_t /*size*/, int /*tag*/)
- {
- BOOST_CHECK(count_constructions > 0);
- if(count_constructions > 0) --count_constructions;
- }
- };
- }
-}
-
-#endif

Modified: trunk/libs/unordered/test/objects/test.hpp
==============================================================================
--- trunk/libs/unordered/test/objects/test.hpp (original)
+++ trunk/libs/unordered/test/objects/test.hpp 2008-06-21 18:02:15 EDT (Sat, 21 Jun 2008)
@@ -12,7 +12,7 @@
 #include <iostream>
 #include "../helpers/fwd.hpp"
 #include "../helpers/count.hpp"
-#include "./memory.hpp"
+#include "../helpers/memory.hpp"
 #include <map>
 
 namespace test
@@ -156,6 +156,11 @@
 
     namespace detail
     {
+ // This won't be a problem as I'm only using a single compile unit
+ // in each test (this is actually require by the minimal test
+ // framework).
+ //
+ // boostinspect:nounnamed
         namespace {
             test::detail::memory_tracker<std::allocator<int> > tracker;
         }

Modified: trunk/libs/unordered/test/unordered/equality_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/equality_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/equality_tests.cpp 2008-06-21 18:02:15 EDT (Sat, 21 Jun 2008)
@@ -25,118 +25,118 @@
     };
 
 #define UNORDERED_EQUALITY_SET_TEST(seq1, op, seq2) \
- do { \
- boost::unordered_set<int, mod_compare, mod_compare> set1, set2; \
- BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \
- BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \
- BOOST_CHECK(set1 op set2); \
- } while(false)
+ do { \
+ boost::unordered_set<int, mod_compare, mod_compare> set1, set2; \
+ BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \
+ BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \
+ BOOST_CHECK(set1 op set2); \
+ } while(false)
 
 #define UNORDERED_EQUALITY_MULTISET_TEST(seq1, op, seq2) \
- do { \
- boost::unordered_multiset<int, mod_compare, mod_compare> set1, set2; \
- BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \
- BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \
- BOOST_CHECK(set1 op set2); \
- } while(false)
+ do { \
+ boost::unordered_multiset<int, mod_compare, mod_compare> set1, set2; \
+ BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \
+ BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \
+ BOOST_CHECK(set1 op set2); \
+ } while(false)
 
 #define UNORDERED_EQUALITY_MAP_TEST(seq1, op, seq2) \
- do { \
- boost::unordered_map<int, int, mod_compare, mod_compare> map1, map2; \
- BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \
- BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \
- BOOST_CHECK(map1 op map2); \
- } while(false)
+ do { \
+ boost::unordered_map<int, int, mod_compare, mod_compare> map1, map2; \
+ BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \
+ BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \
+ BOOST_CHECK(map1 op map2); \
+ } while(false)
 
 #define UNORDERED_EQUALITY_MULTIMAP_TEST(seq1, op, seq2) \
- do { \
- boost::unordered_multimap<int, int, mod_compare, mod_compare> map1, map2; \
- BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \
- BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \
- BOOST_CHECK(map1 op map2); \
- } while(false)
+ do { \
+ boost::unordered_multimap<int, int, mod_compare, mod_compare> map1, map2; \
+ BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \
+ BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \
+ BOOST_CHECK(map1 op map2); \
+ } while(false)
 
 #define UNORDERED_SET_INSERT(r, set, item) set.insert(item);
 #define UNORDERED_MAP_INSERT(r, map, item) \
- map.insert(std::pair<int const, int> BOOST_PP_SEQ_TO_TUPLE(item));
+ map.insert(std::pair<int const, int> BOOST_PP_SEQ_TO_TUPLE(item));
 
- UNORDERED_AUTO_TEST(equality_size_tests)
- {
- boost::unordered_set<int> x1, x2;
- BOOST_CHECK(x1 == x2);
- BOOST_CHECK(!(x1 != x2));
-
- x1.insert(1);
- BOOST_CHECK(x1 != x2);
- BOOST_CHECK(!(x1 == x2));
- BOOST_CHECK(x2 != x1);
- BOOST_CHECK(!(x2 == x1));
-
- x2.insert(1);
- BOOST_CHECK(x1 == x2);
- BOOST_CHECK(!(x1 != x2));
-
- x2.insert(2);
- BOOST_CHECK(x1 != x2);
- BOOST_CHECK(!(x1 == x2));
- BOOST_CHECK(x2 != x1);
- BOOST_CHECK(!(x2 == x1));
- }
-
- UNORDERED_AUTO_TEST(equality_key_value_tests)
- {
- UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (2));
- UNORDERED_EQUALITY_SET_TEST((2), ==, (2));
- UNORDERED_EQUALITY_MAP_TEST(((1)(1))((2)(1)), !=, ((1)(1))((3)(1)));
- }
-
+ UNORDERED_AUTO_TEST(equality_size_tests)
+ {
+ boost::unordered_set<int> x1, x2;
+ BOOST_CHECK(x1 == x2);
+ BOOST_CHECK(!(x1 != x2));
+
+ x1.insert(1);
+ BOOST_CHECK(x1 != x2);
+ BOOST_CHECK(!(x1 == x2));
+ BOOST_CHECK(x2 != x1);
+ BOOST_CHECK(!(x2 == x1));
+
+ x2.insert(1);
+ BOOST_CHECK(x1 == x2);
+ BOOST_CHECK(!(x1 != x2));
+
+ x2.insert(2);
+ BOOST_CHECK(x1 != x2);
+ BOOST_CHECK(!(x1 == x2));
+ BOOST_CHECK(x2 != x1);
+ BOOST_CHECK(!(x2 == x1));
+ }
+
+ UNORDERED_AUTO_TEST(equality_key_value_tests)
+ {
+ UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (2));
+ UNORDERED_EQUALITY_SET_TEST((2), ==, (2));
+ UNORDERED_EQUALITY_MAP_TEST(((1)(1))((2)(1)), !=, ((1)(1))((3)(1)));
+ }
+
     UNORDERED_AUTO_TEST(equality_collision_test)
     {
- UNORDERED_EQUALITY_MULTISET_TEST(
- (1), !=, (501));
- UNORDERED_EQUALITY_MULTISET_TEST(
- (1)(251), !=, (1)(501));
- UNORDERED_EQUALITY_MULTIMAP_TEST(
- ((251)(1))((1)(1)), !=, ((501)(1))((1)(1)));
- UNORDERED_EQUALITY_MULTISET_TEST(
- (1)(501), ==, (1)(501));
- UNORDERED_EQUALITY_SET_TEST(
- (1)(501), ==, (501)(1));
- }
-
- UNORDERED_AUTO_TEST(equality_group_size_test)
- {
- UNORDERED_EQUALITY_MULTISET_TEST(
- (10)(20)(20), !=, (10)(10)(20));
- UNORDERED_EQUALITY_MULTIMAP_TEST(
- ((10)(1))((20)(1))((20)(1)), !=,
- ((10)(1))((20)(1))((10)(1)));
- UNORDERED_EQUALITY_MULTIMAP_TEST(
- ((20)(1))((10)(1))((10)(1)), ==,
- ((10)(1))((20)(1))((10)(1)));
+ UNORDERED_EQUALITY_MULTISET_TEST(
+ (1), !=, (501));
+ UNORDERED_EQUALITY_MULTISET_TEST(
+ (1)(251), !=, (1)(501));
+ UNORDERED_EQUALITY_MULTIMAP_TEST(
+ ((251)(1))((1)(1)), !=, ((501)(1))((1)(1)));
+ UNORDERED_EQUALITY_MULTISET_TEST(
+ (1)(501), ==, (1)(501));
+ UNORDERED_EQUALITY_SET_TEST(
+ (1)(501), ==, (501)(1));
+ }
+
+ UNORDERED_AUTO_TEST(equality_group_size_test)
+ {
+ UNORDERED_EQUALITY_MULTISET_TEST(
+ (10)(20)(20), !=, (10)(10)(20));
+ UNORDERED_EQUALITY_MULTIMAP_TEST(
+ ((10)(1))((20)(1))((20)(1)), !=,
+ ((10)(1))((20)(1))((10)(1)));
+ UNORDERED_EQUALITY_MULTIMAP_TEST(
+ ((20)(1))((10)(1))((10)(1)), ==,
+ ((10)(1))((20)(1))((10)(1)));
     }
     
     UNORDERED_AUTO_TEST(equality_map_value_test)
     {
- UNORDERED_EQUALITY_MAP_TEST(
- ((1)(1)), !=, ((1)(2)));
- UNORDERED_EQUALITY_MAP_TEST(
- ((1)(1)), ==, ((1)(1)));
- UNORDERED_EQUALITY_MULTIMAP_TEST(
- ((1)(1)), !=, ((1)(2)));
- UNORDERED_EQUALITY_MULTIMAP_TEST(
- ((1)(1))((1)(1)), !=, ((1)(1))((1)(2)));
- UNORDERED_EQUALITY_MULTIMAP_TEST(
- ((1)(2))((1)(1)), !=, ((1)(1))((1)(2)));
- }
+ UNORDERED_EQUALITY_MAP_TEST(
+ ((1)(1)), !=, ((1)(2)));
+ UNORDERED_EQUALITY_MAP_TEST(
+ ((1)(1)), ==, ((1)(1)));
+ UNORDERED_EQUALITY_MULTIMAP_TEST(
+ ((1)(1)), !=, ((1)(2)));
+ UNORDERED_EQUALITY_MULTIMAP_TEST(
+ ((1)(1))((1)(1)), !=, ((1)(1))((1)(2)));
+ UNORDERED_EQUALITY_MULTIMAP_TEST(
+ ((1)(2))((1)(1)), !=, ((1)(1))((1)(2)));
+ }
 
     UNORDERED_AUTO_TEST(equality_predicate_test)
     {
- UNORDERED_EQUALITY_SET_TEST(
- (1), ==, (1001));
- UNORDERED_EQUALITY_MAP_TEST(
- ((1)(2))((1001)(1)), ==, ((1001)(2))((1)(1)));
- }
+ UNORDERED_EQUALITY_SET_TEST(
+ (1), ==, (1001));
+ UNORDERED_EQUALITY_MAP_TEST(
+ ((1)(2))((1001)(1)), ==, ((1001)(2))((1)(1)));
+ }
 
 }
 


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