diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-06-02 03:12:44 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-06-02 03:12:44 +0000 |
commit | d697ee41bc77a1fb89daf718f5986f91b0f881e6 (patch) | |
tree | fc9dd2e58019ee28e1ec03f52b8680f308b6b19e /libcxx/test/std/utilities/function.objects | |
parent | 6c53d8f94c5b0c3c7d612110f85006a997451309 (diff) | |
download | bcm5719-llvm-d697ee41bc77a1fb89daf718f5986f91b0f881e6.tar.gz bcm5719-llvm-d697ee41bc77a1fb89daf718f5986f91b0f881e6.zip |
Mark LWG issue 2450 as complete.
llvm-svn: 271473
Diffstat (limited to 'libcxx/test/std/utilities/function.objects')
7 files changed, 80 insertions, 6 deletions
diff --git a/libcxx/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp b/libcxx/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp index 60415ec75d6..d4d99756fec 100644 --- a/libcxx/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp @@ -15,6 +15,8 @@ #include <type_traits> #include <cassert> +#include "test_macros.h" + int main() { typedef std::equal_to<int> F; @@ -24,7 +26,7 @@ int main() static_assert((std::is_same<bool, F::result_type>::value), "" ); assert(f(36, 36)); assert(!f(36, 6)); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 typedef std::equal_to<> F2; const F2 f2 = F2(); assert(f2(36, 36)); diff --git a/libcxx/test/std/utilities/function.objects/comparisons/greater.pass.cpp b/libcxx/test/std/utilities/function.objects/comparisons/greater.pass.cpp index 164f09aa605..50bdcceee1c 100644 --- a/libcxx/test/std/utilities/function.objects/comparisons/greater.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/comparisons/greater.pass.cpp @@ -15,6 +15,9 @@ #include <type_traits> #include <cassert> +#include "test_macros.h" +#include "pointer_comparison_test_helper.hpp" + int main() { typedef std::greater<int> F; @@ -25,7 +28,12 @@ int main() assert(!f(36, 36)); assert(f(36, 6)); assert(!f(6, 36)); -#if _LIBCPP_STD_VER > 11 + { + // test total ordering of int* for greater<int*> and + // greater<void>. + do_pointer_comparison_test<int, std::greater>(); + } +#if TEST_STD_VER > 11 typedef std::greater<> F2; const F2 f2 = F2(); assert(!f2(36, 36)); diff --git a/libcxx/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp b/libcxx/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp index e89c14e2462..0aacb81e9cb 100644 --- a/libcxx/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp @@ -15,6 +15,9 @@ #include <type_traits> #include <cassert> +#include "test_macros.h" +#include "pointer_comparison_test_helper.hpp" + int main() { typedef std::greater_equal<int> F; @@ -25,7 +28,12 @@ int main() assert(f(36, 36)); assert(f(36, 6)); assert(!f(6, 36)); -#if _LIBCPP_STD_VER > 11 + { + // test total ordering of int* for greater_equal<int*> and + // greater_equal<void>. + do_pointer_comparison_test<int, std::greater_equal>(); + } +#if TEST_STD_VER > 11 typedef std::greater_equal<> F2; const F2 f2 = F2(); assert(f2(36, 36)); diff --git a/libcxx/test/std/utilities/function.objects/comparisons/less.pass.cpp b/libcxx/test/std/utilities/function.objects/comparisons/less.pass.cpp index 74fe166a0cd..191d58d6e54 100644 --- a/libcxx/test/std/utilities/function.objects/comparisons/less.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/comparisons/less.pass.cpp @@ -15,6 +15,9 @@ #include <type_traits> #include <cassert> +#include "test_macros.h" +#include "pointer_comparison_test_helper.hpp" + int main() { typedef std::less<int> F; @@ -25,7 +28,11 @@ int main() assert(!f(36, 36)); assert(!f(36, 6)); assert(f(6, 36)); -#if _LIBCPP_STD_VER > 11 + { + // test total ordering of int* for less<int*> and less<void>. + do_pointer_comparison_test<int, std::less>(); + } +#if TEST_STD_VER > 11 typedef std::less<> F2; const F2 f2 = F2(); assert(!f2(36, 36)); diff --git a/libcxx/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp b/libcxx/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp index e6ba1f7f8a2..a6aca5d1956 100644 --- a/libcxx/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp @@ -15,6 +15,9 @@ #include <type_traits> #include <cassert> +#include "test_macros.h" +#include "pointer_comparison_test_helper.hpp" + int main() { typedef std::less_equal<int> F; @@ -25,7 +28,12 @@ int main() assert(f(36, 36)); assert(!f(36, 6)); assert(f(6, 36)); -#if _LIBCPP_STD_VER > 11 + { + // test total ordering of int* for less_equal<int*> and + // less_equal<void>. + do_pointer_comparison_test<int, std::less_equal>(); + } +#if TEST_STD_VER > 11 typedef std::less_equal<> F2; const F2 f2 = F2(); assert( f2(36, 36)); diff --git a/libcxx/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp b/libcxx/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp index 3e710b3e0c7..777c25d520a 100644 --- a/libcxx/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp @@ -15,6 +15,8 @@ #include <type_traits> #include <cassert> +#include "test_macros.h" + int main() { typedef std::not_equal_to<int> F; @@ -24,7 +26,7 @@ int main() static_assert((std::is_same<bool, F::result_type>::value), "" ); assert(!f(36, 36)); assert(f(36, 6)); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 typedef std::not_equal_to<> F2; const F2 f2 = F2(); assert(!f2(36, 36)); diff --git a/libcxx/test/std/utilities/function.objects/comparisons/pointer_comparison_test_helper.hpp b/libcxx/test/std/utilities/function.objects/comparisons/pointer_comparison_test_helper.hpp new file mode 100644 index 00000000000..66d783a6e35 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/comparisons/pointer_comparison_test_helper.hpp @@ -0,0 +1,39 @@ +#ifndef POINTER_COMPARISON_TEST_HELPER_HPP +#define POINTER_COMPARISON_TEST_HELPER_HPP + +#include <vector> +#include <memory> +#include <cstdint> +#include <cassert> + +#include "test_macros.h" + +template <class T, template<class> class CompareTemplate> +void do_pointer_comparison_test() { + typedef CompareTemplate<T*> Compare; + typedef CompareTemplate<std::uintptr_t> UIntCompare; +#if TEST_STD_VER > 11 + typedef CompareTemplate<void> VoidCompare; +#else + typedef Compare VoidCompare; +#endif + std::vector<std::shared_ptr<T> > pointers; + const std::size_t test_size = 100; + for (int i=0; i < test_size; ++i) + pointers.push_back(std::shared_ptr<T>(new T())); + Compare comp; + UIntCompare ucomp; + VoidCompare vcomp; + for (int i=0; i < test_size; ++i) { + for (int j=0; j < test_size; ++j) { + T* lhs = pointers[i].get(); + T* rhs = pointers[j].get(); + std::uintptr_t lhs_uint = reinterpret_cast<std::uintptr_t>(lhs); + std::uintptr_t rhs_uint = reinterpret_cast<std::uintptr_t>(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 |