From 8868fa46873137e89da03ceaf09e0c4f01f1329b Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 21 Jun 2008 22:02:15 +0000 Subject: [PATCH] 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. ................ [SVN r46594] --- doc/bibliography.xml | 5 + examples/hash_functions/fnv-1.hpp | 7 +- test/helpers/count.hpp | 5 + test/helpers/equivalent.hpp | 5 + test/{objects => helpers}/memory.hpp | 0 test/objects/exception.hpp | 2 +- test/objects/test.hpp | 7 +- test/unordered/equality_tests.cpp | 180 +++++++++++++-------------- 8 files changed, 118 insertions(+), 93 deletions(-) rename test/{objects => helpers}/memory.hpp (100%) diff --git a/doc/bibliography.xml b/doc/bibliography.xml index 9a874073..1f2f077e 100644 --- a/doc/bibliography.xml +++ b/doc/bibliography.xml @@ -1,3 +1,8 @@ +
Bibliography diff --git a/examples/hash_functions/fnv-1.hpp b/examples/hash_functions/fnv-1.hpp index 3c9ce63b..9caf1687 100644 --- a/examples/hash_functions/fnv-1.hpp +++ b/examples/hash_functions/fnv-1.hpp @@ -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 diff --git a/test/helpers/count.hpp b/test/helpers/count.hpp index 6e3478da..15bff3b0 100644 --- a/test/helpers/count.hpp +++ b/test/helpers/count.hpp @@ -53,6 +53,11 @@ namespace test { struct globally_counted_object : 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_; } diff --git a/test/helpers/equivalent.hpp b/test/helpers/equivalent.hpp index ec605fc2..dedadc77 100644 --- a/test/helpers/equivalent.hpp +++ b/test/helpers/equivalent.hpp @@ -44,6 +44,11 @@ namespace test } }; + // 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; } diff --git a/test/objects/memory.hpp b/test/helpers/memory.hpp similarity index 100% rename from test/objects/memory.hpp rename to test/helpers/memory.hpp diff --git a/test/objects/exception.hpp b/test/objects/exception.hpp index 9e10c4e4..c75880d3 100644 --- a/test/objects/exception.hpp +++ b/test/objects/exception.hpp @@ -14,7 +14,7 @@ #include #include "../helpers/fwd.hpp" #include "../helpers/allocator.hpp" -#include "./memory.hpp" +#include "../helpers/memory.hpp" namespace test { diff --git a/test/objects/test.hpp b/test/objects/test.hpp index fd1b6ddf..04bdd4bb 100644 --- a/test/objects/test.hpp +++ b/test/objects/test.hpp @@ -12,7 +12,7 @@ #include #include "../helpers/fwd.hpp" #include "../helpers/count.hpp" -#include "./memory.hpp" +#include "../helpers/memory.hpp" #include namespace test @@ -156,6 +156,11 @@ namespace test 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 > tracker; } diff --git a/test/unordered/equality_tests.cpp b/test/unordered/equality_tests.cpp index c1738a27..ff0e6b57 100644 --- a/test/unordered/equality_tests.cpp +++ b/test/unordered/equality_tests.cpp @@ -25,118 +25,118 @@ namespace equality_tests }; #define UNORDERED_EQUALITY_SET_TEST(seq1, op, seq2) \ - do { \ - boost::unordered_set 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 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 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 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 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 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 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 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 BOOST_PP_SEQ_TO_TUPLE(item)); + map.insert(std::pair BOOST_PP_SEQ_TO_TUPLE(item)); - UNORDERED_AUTO_TEST(equality_size_tests) - { - boost::unordered_set x1, x2; - BOOST_CHECK(x1 == x2); - BOOST_CHECK(!(x1 != x2)); + UNORDERED_AUTO_TEST(equality_size_tests) + { + boost::unordered_set 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))); - } - + 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_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_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))); + } }