// Copyright Daniel James 2005. Use, modification, and distribution are // subject to 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_TESTS_STRONG_HEADER) #define BOOST_UNORDERED_TESTS_STRONG_HEADER #include "./helpers/strong.hpp" #include "./helpers/equivalent.hpp" #include "./helpers/metafunctions.hpp" #include #include #include #include namespace test { struct equals_t { template bool operator()(X const& x, Y const& y) { return x == y; } template bool operator()(std::pair const& x, std::pair const& y) { return x.first == y.first && x.second == y.second; } } equals1; template class unordered_strong_tester : public strong_tester { Container const& reference_; typename Container::size_type size_; typename Container::hasher hasher_; typename Container::key_equal key_equal_; std::deque::type> values_; public: unordered_strong_tester(Container const &x) : reference_(x), size_(x.size()), hasher_(x.hash_function()), key_equal_(x.key_eq()), values_(x.begin(), x.end()) { } void test() { BOOST_CHECK(size_ == reference_.size()); BOOST_CHECK(test::equivalent(hasher_, reference_.hash_function())); BOOST_CHECK(test::equivalent(key_equal_, reference_.key_eq())); BOOST_CHECK(values_.size() == reference_.size()); BOOST_CHECK(values_.size() == reference_.size() && std::equal(values_.begin(), values_.end(), reference_.begin(), equals1)); } private: unordered_strong_tester(); }; } namespace boost { template test::strong_tester_ptr create_tester_impl( boost::unordered_set const& x, int) { return test::strong_tester_ptr(new test::unordered_strong_tester< boost::unordered_set >(x)); } template test::strong_tester_ptr create_tester_impl( boost::unordered_multiset const& x, int) { return test::strong_tester_ptr(new test::unordered_strong_tester< boost::unordered_multiset >(x)); } template test::strong_tester_ptr create_tester_impl( boost::unordered_map const& x, int) { return test::strong_tester_ptr(new test::unordered_strong_tester< boost::unordered_map >(x)); } template test::strong_tester_ptr create_tester_impl( boost::unordered_multimap const& x, int) { return test::strong_tester_ptr(new test::unordered_strong_tester< boost::unordered_multimap >(x)); } } #endif