summaryrefslogtreecommitdiff
path: root/test/std/utilities/function.objects/bitwise.operations
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-09-06 18:46:46 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-09-06 18:46:46 +0000
commit61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch)
treeec41ed70ffca97240e76f9a78bb2dedba28f310c /test/std/utilities/function.objects/bitwise.operations
parentf857581820d15e410e9945d2fcd5f7163be25a96 (diff)
Notes
Diffstat (limited to 'test/std/utilities/function.objects/bitwise.operations')
-rw-r--r--test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp59
-rw-r--r--test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp47
-rw-r--r--test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp59
-rw-r--r--test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp63
-rw-r--r--test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp51
5 files changed, 279 insertions, 0 deletions
diff --git a/test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp b/test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp
new file mode 100644
index 0000000000000..c0135fad19827
--- /dev/null
+++ b/test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// bit_and
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::bit_and<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<int, F::result_type>::value), "" );
+ assert(f(0xEA95, 0xEA95) == 0xEA95);
+ assert(f(0xEA95, 0x58D3) == 0x4891);
+ assert(f(0x58D3, 0xEA95) == 0x4891);
+ assert(f(0x58D3, 0) == 0);
+ assert(f(0xFFFF, 0x58D3) == 0x58D3);
+#if _LIBCPP_STD_VER > 11
+ typedef std::bit_and<> F2;
+ const F2 f2 = F2();
+ assert(f2(0xEA95, 0xEA95) == 0xEA95);
+ assert(f2(0xEA95L, 0xEA95) == 0xEA95);
+ assert(f2(0xEA95, 0xEA95L) == 0xEA95);
+
+ assert(f2(0xEA95, 0x58D3) == 0x4891);
+ assert(f2(0xEA95L, 0x58D3) == 0x4891);
+ assert(f2(0xEA95, 0x58D3L) == 0x4891);
+
+ assert(f2(0x58D3, 0xEA95) == 0x4891);
+ assert(f2(0x58D3L, 0xEA95) == 0x4891);
+ assert(f2(0x58D3, 0xEA95L) == 0x4891);
+
+ assert(f2(0x58D3, 0) == 0);
+ assert(f2(0x58D3L, 0) == 0);
+ assert(f2(0x58D3, 0L) == 0);
+
+ assert(f2(0xFFFF, 0x58D3) == 0x58D3);
+ assert(f2(0xFFFFL, 0x58D3) == 0x58D3);
+ assert(f2(0xFFFF, 0x58D3L) == 0x58D3);
+
+ constexpr int foo = std::bit_and<int> () (0x58D3, 0xEA95);
+ static_assert ( foo == 0x4891, "" );
+
+ constexpr int bar = std::bit_and<> () (0x58D3L, 0xEA95);
+ static_assert ( bar == 0x4891, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp b/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp
new file mode 100644
index 0000000000000..48800a366a81c
--- /dev/null
+++ b/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// bit_not
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::bit_not<int> F;
+ const F f = F();
+ static_assert((std::is_same<F::argument_type, int>::value), "" );
+ static_assert((std::is_same<F::result_type, int>::value), "" );
+ assert((f(0xEA95) & 0xFFFF ) == 0x156A);
+ assert((f(0x58D3) & 0xFFFF ) == 0xA72C);
+ assert((f(0) & 0xFFFF ) == 0xFFFF);
+ assert((f(0xFFFF) & 0xFFFF ) == 0);
+
+ typedef std::bit_not<> F2;
+ const F2 f2 = F2();
+ assert((f2(0xEA95) & 0xFFFF ) == 0x156A);
+ assert((f2(0xEA95L) & 0xFFFF ) == 0x156A);
+ assert((f2(0x58D3) & 0xFFFF ) == 0xA72C);
+ assert((f2(0x58D3L) & 0xFFFF ) == 0xA72C);
+ assert((f2(0) & 0xFFFF ) == 0xFFFF);
+ assert((f2(0L) & 0xFFFF ) == 0xFFFF);
+ assert((f2(0xFFFF) & 0xFFFF ) == 0);
+ assert((f2(0xFFFFL) & 0xFFFF ) == 0);
+
+ constexpr int foo = std::bit_not<int> () (0xEA95) & 0xFFFF;
+ static_assert ( foo == 0x156A, "" );
+
+ constexpr int bar = std::bit_not<> () (0xEA95) & 0xFFFF;
+ static_assert ( bar == 0x156A, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp b/test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp
new file mode 100644
index 0000000000000..cb33df3d84b7f
--- /dev/null
+++ b/test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// bit_or
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::bit_or<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<int, F::result_type>::value), "" );
+ assert(f(0xEA95, 0xEA95) == 0xEA95);
+ assert(f(0xEA95, 0x58D3) == 0xFAD7);
+ assert(f(0x58D3, 0xEA95) == 0xFAD7);
+ assert(f(0x58D3, 0) == 0x58D3);
+ assert(f(0xFFFF, 0x58D3) == 0xFFFF);
+#if _LIBCPP_STD_VER > 11
+ typedef std::bit_or<> F2;
+ const F2 f2 = F2();
+ assert(f2(0xEA95, 0xEA95) == 0xEA95);
+ assert(f2(0xEA95L, 0xEA95) == 0xEA95);
+ assert(f2(0xEA95, 0xEA95L) == 0xEA95);
+
+ assert(f2(0xEA95, 0x58D3) == 0xFAD7);
+ assert(f2(0xEA95L, 0x58D3) == 0xFAD7);
+ assert(f2(0xEA95, 0x58D3L) == 0xFAD7);
+
+ assert(f2(0x58D3, 0xEA95) == 0xFAD7);
+ assert(f2(0x58D3L, 0xEA95) == 0xFAD7);
+ assert(f2(0x58D3, 0xEA95L) == 0xFAD7);
+
+ assert(f2(0x58D3, 0) == 0x58D3);
+ assert(f2(0x58D3L, 0) == 0x58D3);
+ assert(f2(0x58D3, 0L) == 0x58D3);
+
+ assert(f2(0xFFFF, 0x58D3) == 0xFFFF);
+ assert(f2(0xFFFFL, 0x58D3) == 0xFFFF);
+ assert(f2(0xFFFF, 0x58D3L) == 0xFFFF);
+
+ constexpr int foo = std::bit_or<int> () (0x58D3, 0xEA95);
+ static_assert ( foo == 0xFAD7, "" );
+
+ constexpr int bar = std::bit_or<> () (0x58D3L, 0xEA95);
+ static_assert ( bar == 0xFAD7, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp b/test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp
new file mode 100644
index 0000000000000..bbf2ce5baf1bb
--- /dev/null
+++ b/test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// bit_xor
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bit_xor<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<int, F::result_type>::value), "" );
+ assert(f(0xEA95, 0xEA95) == 0);
+ assert(f(0xEA95, 0x58D3) == 0xB246);
+ assert(f(0x58D3, 0xEA95) == 0xB246);
+ assert(f(0x58D3, 0) == 0x58D3);
+ assert(f(0xFFFF, 0x58D3) == 0xA72C);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::bit_xor<> F2;
+ const F2 f = F2();
+ assert(f(0xEA95, 0xEA95) == 0);
+ assert(f(0xEA95L, 0xEA95) == 0);
+ assert(f(0xEA95, 0xEA95L) == 0);
+
+ assert(f(0xEA95, 0x58D3) == 0xB246);
+ assert(f(0xEA95L, 0x58D3) == 0xB246);
+ assert(f(0xEA95, 0x58D3L) == 0xB246);
+
+ assert(f(0x58D3, 0xEA95) == 0xB246);
+ assert(f(0x58D3L, 0xEA95) == 0xB246);
+ assert(f(0x58D3, 0xEA95L) == 0xB246);
+
+ assert(f(0x58D3, 0) == 0x58D3);
+ assert(f(0x58D3L, 0) == 0x58D3);
+ assert(f(0x58D3, 0L) == 0x58D3);
+
+ assert(f(0xFFFF, 0x58D3) == 0xA72C);
+ assert(f(0xFFFFL, 0x58D3) == 0xA72C);
+ assert(f(0xFFFF, 0x58D3L) == 0xA72C);
+
+ constexpr int foo = std::bit_xor<int> () (0x58D3, 0xEA95);
+ static_assert ( foo == 0xB246, "" );
+
+ constexpr int bar = std::bit_xor<> () (0x58D3L, 0xEA95);
+ static_assert ( bar == 0xB246, "" );
+ }
+#endif
+}
diff --git a/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp b/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp
new file mode 100644
index 0000000000000..9f8e15dd55fe0
--- /dev/null
+++ b/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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::bit_and<int>>::value, "" );
+ static_assert ( !is_transparent<std::bit_and<std::string>>::value, "" );
+ static_assert ( is_transparent<std::bit_and<void>>::value, "" );
+ static_assert ( is_transparent<std::bit_and<>>::value, "" );
+
+ static_assert ( !is_transparent<std::bit_or<int>>::value, "" );
+ static_assert ( !is_transparent<std::bit_or<std::string>>::value, "" );
+ static_assert ( is_transparent<std::bit_or<void>>::value, "" );
+ static_assert ( is_transparent<std::bit_or<>>::value, "" );
+
+ static_assert ( !is_transparent<std::bit_xor<int>>::value, "" );
+ static_assert ( !is_transparent<std::bit_xor<std::string>>::value, "" );
+ static_assert ( is_transparent<std::bit_xor<void>>::value, "" );
+ static_assert ( is_transparent<std::bit_xor<>>::value, "" );
+
+ static_assert ( !is_transparent<std::bit_not<int>>::value, "" );
+ static_assert ( !is_transparent<std::bit_not<std::string>>::value, "" );
+ static_assert ( is_transparent<std::bit_not<void>>::value, "" );
+ static_assert ( is_transparent<std::bit_not<>>::value, "" );
+
+#endif
+
+ return 0;
+ }