hash_pointer_test.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2005-2009 Daniel James.
  2. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #include "./config.hpp"
  5. #ifdef BOOST_HASH_TEST_STD_INCLUDES
  6. # include <functional>
  7. #else
  8. # include <boost/container_hash/hash.hpp>
  9. #endif
  10. #include <boost/core/lightweight_test.hpp>
  11. #include <boost/limits.hpp>
  12. #include "./compile_time.hpp"
  13. void pointer_tests()
  14. {
  15. compile_time_tests((int**) 0);
  16. compile_time_tests((void**) 0);
  17. BOOST_HASH_TEST_NAMESPACE::hash<int*> x1;
  18. BOOST_HASH_TEST_NAMESPACE::hash<int*> x2;
  19. int int1;
  20. int int2;
  21. BOOST_TEST(x1(0) == x2(0));
  22. BOOST_TEST(x1(&int1) == x2(&int1));
  23. BOOST_TEST(x1(&int2) == x2(&int2));
  24. #if defined(BOOST_HASH_TEST_EXTENSIONS)
  25. BOOST_TEST(x1(&int1) == BOOST_HASH_TEST_NAMESPACE::hash_value(&int1));
  26. BOOST_TEST(x1(&int2) == BOOST_HASH_TEST_NAMESPACE::hash_value(&int2));
  27. // This isn't specified in Peter's proposal:
  28. BOOST_TEST(x1(0) == 0);
  29. #endif
  30. }
  31. int main()
  32. {
  33. pointer_tests();
  34. return boost::report_errors();
  35. }