From 3fd5635d7d831943191e5b51781649d4ebebef62 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 23 Mar 2011 00:07:17 +0000 Subject: [PATCH] Unordered: Fix some overly strict tests. [SVN r70443] --- test/objects/test.hpp | 65 ++++++++++------------- test/unordered/insert_tests.cpp | 4 +- test/unordered/unnecessary_copy_tests.cpp | 2 +- 3 files changed, 30 insertions(+), 41 deletions(-) diff --git a/test/objects/test.hpp b/test/objects/test.hpp index bfada4d2..44a241d2 100644 --- a/test/objects/test.hpp +++ b/test/objects/test.hpp @@ -20,11 +20,13 @@ namespace test // Note that the default hash function will work for any equal_to (but not // very well). class object; + class implicitly_convertible; class hash; class less; class equal_to; template class allocator; object generate(object const*); + implicitly_convertible generate(implicitly_convertible const*); class object : globally_counted_object { @@ -64,6 +66,31 @@ namespace test } }; + class implicitly_convertible : globally_counted_object + { + int tag1_, tag2_; + public: + + explicit implicitly_convertible(int t1 = 0, int t2 = 0) + : tag1_(t1), tag2_(t2) + {} + + operator object() const + { + return object(tag1_, tag2_); + } + + friend implicitly_convertible generate(implicitly_convertible const*) { + int* x = 0; + return implicitly_convertible(generate(x), generate(x)); + } + + friend std::ostream& operator<<(std::ostream& out, implicitly_convertible const& o) + { + return out<<"("< - void swap(test::allocator& x, test::allocator& y) { - test::allocator tmp; - tmp = x; - x = y; - y = tmp; - } -#endif } #endif diff --git a/test/unordered/insert_tests.cpp b/test/unordered/insert_tests.cpp index d832c7d2..30d6bd8d 100644 --- a/test/unordered/insert_tests.cpp +++ b/test/unordered/insert_tests.cpp @@ -372,10 +372,10 @@ void map_insert_range_test2(X*, std::cerr<<"map_insert_range_test2\n"; typedef test::list< - std::pair + std::pair > list; test::random_values< - boost::unordered_map + boost::unordered_map > v(1000, generator); list l(v.begin(), v.end()); diff --git a/test/unordered/unnecessary_copy_tests.cpp b/test/unordered/unnecessary_copy_tests.cpp index 58bc3b70..2f59f2fa 100644 --- a/test/unordered/unnecessary_copy_tests.cpp +++ b/test/unordered/unnecessary_copy_tests.cpp @@ -261,7 +261,7 @@ namespace unnecessary_copy_tests // copied. reset(); x.emplace(source >()); - COPY_COUNT(2); MOVE_COUNT(0); + COPY_COUNT(2); MOVE_COUNT_RANGE(0,2); // TODO: This doesn't work on older versions of gcc. //count_copies part;