#ifndef POINTER_COMPARISON_TEST_HELPER_HPP #define POINTER_COMPARISON_TEST_HELPER_HPP #include #include #include #include #include "test_macros.h" template class CompareTemplate> void do_pointer_comparison_test() { typedef CompareTemplate Compare; typedef CompareTemplate UIntCompare; #if TEST_STD_VER > 11 typedef CompareTemplate VoidCompare; #else typedef Compare VoidCompare; #endif std::vector > pointers; const std::size_t test_size = 100; for (size_t i=0; i < test_size; ++i) pointers.push_back(std::shared_ptr(new T())); Compare comp; UIntCompare ucomp; VoidCompare vcomp; for (size_t i=0; i < test_size; ++i) { for (size_t j=0; j < test_size; ++j) { T* lhs = pointers[i].get(); T* rhs = pointers[j].get(); std::uintptr_t lhs_uint = reinterpret_cast(lhs); std::uintptr_t rhs_uint = reinterpret_cast(rhs); assert(comp(lhs, rhs) == ucomp(lhs_uint, rhs_uint)); assert(vcomp(lhs, rhs) == ucomp(lhs_uint, rhs_uint)); } } } #endif // POINTER_COMPARISON_TEST_HELPER_HPP