summaryrefslogtreecommitdiff
path: root/test/std/utilities/function.objects/comparisons
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/utilities/function.objects/comparisons')
-rw-r--r--test/std/utilities/function.objects/comparisons/equal_to.pass.cpp41
-rw-r--r--test/std/utilities/function.objects/comparisons/greater.pass.cpp45
-rw-r--r--test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp45
-rw-r--r--test/std/utilities/function.objects/comparisons/less.pass.cpp45
-rw-r--r--test/std/utilities/function.objects/comparisons/less_equal.pass.cpp45
-rw-r--r--test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp43
-rw-r--r--test/std/utilities/function.objects/comparisons/transparent.pass.cpp61
7 files changed, 325 insertions, 0 deletions
diff --git a/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp b/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp
new file mode 100644
index 0000000000000..60415ec75d60f
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// equal_to
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::equal_to<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(f(36, 36));
+ assert(!f(36, 6));
+#if _LIBCPP_STD_VER > 11
+ typedef std::equal_to<> F2;
+ const F2 f2 = F2();
+ assert(f2(36, 36));
+ assert(!f2(36, 6));
+ assert(f2(36, 36.0));
+ assert(f2(36.0, 36L));
+
+ constexpr bool foo = std::equal_to<int> () (36, 36);
+ static_assert ( foo, "" );
+
+ constexpr bool bar = std::equal_to<> () (36.0, 36);
+ static_assert ( bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/comparisons/greater.pass.cpp b/test/std/utilities/function.objects/comparisons/greater.pass.cpp
new file mode 100644
index 0000000000000..164f09aa605cc
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/greater.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// greater
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::greater<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(!f(36, 36));
+ assert(f(36, 6));
+ assert(!f(6, 36));
+#if _LIBCPP_STD_VER > 11
+ typedef std::greater<> F2;
+ const F2 f2 = F2();
+ assert(!f2(36, 36));
+ assert(f2(36, 6));
+ assert(!f2(6, 36));
+ assert( f2(36, 6.0));
+ assert( f2(36.0, 6));
+ assert(!f2(6, 36.0));
+ assert(!f2(6.0, 36));
+
+ constexpr bool foo = std::greater<int> () (36, 36);
+ static_assert ( !foo, "" );
+
+ constexpr bool bar = std::greater<> () (36.0, 36);
+ static_assert ( !bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp b/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp
new file mode 100644
index 0000000000000..e89c14e246259
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// greater_equal
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::greater_equal<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(f(36, 36));
+ assert(f(36, 6));
+ assert(!f(6, 36));
+#if _LIBCPP_STD_VER > 11
+ typedef std::greater_equal<> F2;
+ const F2 f2 = F2();
+ assert(f2(36, 36));
+ assert(f2(36, 6));
+ assert(!f2(6, 36));
+ assert( f2(36, 6.0));
+ assert( f2(36.0, 6));
+ assert(!f2(6, 36.0));
+ assert(!f2(6.0, 36));
+
+ constexpr bool foo = std::greater_equal<int> () (36, 36);
+ static_assert ( foo, "" );
+
+ constexpr bool bar = std::greater_equal<> () (36.0, 36);
+ static_assert ( bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/comparisons/less.pass.cpp b/test/std/utilities/function.objects/comparisons/less.pass.cpp
new file mode 100644
index 0000000000000..74fe166a0cd96
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/less.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// less
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::less<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(!f(36, 36));
+ assert(!f(36, 6));
+ assert(f(6, 36));
+#if _LIBCPP_STD_VER > 11
+ typedef std::less<> F2;
+ const F2 f2 = F2();
+ assert(!f2(36, 36));
+ assert(!f2(36, 6));
+ assert( f2(6, 36));
+ assert(!f2(36, 6.0));
+ assert(!f2(36.0, 6));
+ assert( f2(6, 36.0));
+ assert( f2(6.0, 36));
+
+ constexpr bool foo = std::less<int> () (36, 36);
+ static_assert ( !foo, "" );
+
+ constexpr bool bar = std::less<> () (36.0, 36);
+ static_assert ( !bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp b/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp
new file mode 100644
index 0000000000000..e6ba1f7f8a212
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// less_equal
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::less_equal<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(f(36, 36));
+ assert(!f(36, 6));
+ assert(f(6, 36));
+#if _LIBCPP_STD_VER > 11
+ typedef std::less_equal<> F2;
+ const F2 f2 = F2();
+ assert( f2(36, 36));
+ assert(!f2(36, 6));
+ assert( f2(6, 36));
+ assert(!f2(36, 6.0));
+ assert(!f2(36.0, 6));
+ assert( f2(6, 36.0));
+ assert( f2(6.0, 36));
+
+ constexpr bool foo = std::less_equal<int> () (36, 36);
+ static_assert ( foo, "" );
+
+ constexpr bool bar = std::less_equal<> () (36.0, 36);
+ static_assert ( bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp b/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp
new file mode 100644
index 0000000000000..3e710b3e0c70b
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// not_equal_to
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::not_equal_to<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(!f(36, 36));
+ assert(f(36, 6));
+#if _LIBCPP_STD_VER > 11
+ typedef std::not_equal_to<> F2;
+ const F2 f2 = F2();
+ assert(!f2(36, 36));
+ assert( f2(36, 6));
+ assert( f2(36, 6.0));
+ assert( f2(36.0, 6));
+ assert(!f2(36.0, 36));
+ assert(!f2(36, 36.0));
+
+ constexpr bool foo = std::not_equal_to<int> () (36, 36);
+ static_assert ( !foo, "" );
+
+ constexpr bool bar = std::not_equal_to<> () (36.0, 36);
+ static_assert ( !bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/comparisons/transparent.pass.cpp b/test/std/utilities/function.objects/comparisons/transparent.pass.cpp
new file mode 100644
index 0000000000000..41ce4bcae65fd
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/transparent.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ template <class _Up> static __two __test(...);
+ template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+ static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+ static_assert ( !is_transparent<std::less<int>>::value, "" );
+ static_assert ( !is_transparent<std::less<std::string>>::value, "" );
+ static_assert ( is_transparent<std::less<void>>::value, "" );
+ static_assert ( is_transparent<std::less<>>::value, "" );
+
+ static_assert ( !is_transparent<std::less_equal<int>>::value, "" );
+ static_assert ( !is_transparent<std::less_equal<std::string>>::value, "" );
+ static_assert ( is_transparent<std::less_equal<void>>::value, "" );
+ static_assert ( is_transparent<std::less_equal<>>::value, "" );
+
+ static_assert ( !is_transparent<std::equal_to<int>>::value, "" );
+ static_assert ( !is_transparent<std::equal_to<std::string>>::value, "" );
+ static_assert ( is_transparent<std::equal_to<void>>::value, "" );
+ static_assert ( is_transparent<std::equal_to<>>::value, "" );
+
+ static_assert ( !is_transparent<std::not_equal_to<int>>::value, "" );
+ static_assert ( !is_transparent<std::not_equal_to<std::string>>::value, "" );
+ static_assert ( is_transparent<std::not_equal_to<void>>::value, "" );
+ static_assert ( is_transparent<std::not_equal_to<>>::value, "" );
+
+ static_assert ( !is_transparent<std::greater<int>>::value, "" );
+ static_assert ( !is_transparent<std::greater<std::string>>::value, "" );
+ static_assert ( is_transparent<std::greater<void>>::value, "" );
+ static_assert ( is_transparent<std::greater<>>::value, "" );
+
+ static_assert ( !is_transparent<std::greater_equal<int>>::value, "" );
+ static_assert ( !is_transparent<std::greater_equal<std::string>>::value, "" );
+ static_assert ( is_transparent<std::greater_equal<void>>::value, "" );
+ static_assert ( is_transparent<std::greater_equal<>>::value, "" );
+
+#endif
+
+ return 0;
+ }