diff options
Diffstat (limited to 'libcxx/test/libcxx-03/numerics/bit.ops.pass.cpp')
| -rw-r--r-- | libcxx/test/libcxx-03/numerics/bit.ops.pass.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/libcxx/test/libcxx-03/numerics/bit.ops.pass.cpp b/libcxx/test/libcxx-03/numerics/bit.ops.pass.cpp new file mode 100644 index 000000000000..0b82f352ffe3 --- /dev/null +++ b/libcxx/test/libcxx-03/numerics/bit.ops.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// Test the __XXXX routines in the <bit> header. +// These are not supposed to be exhaustive tests, just sanity checks. + +#include <__cxx03/__bit/countl.h> +#include <__cxx03/__bit/rotate.h> +#include <cassert> + +#include "test_macros.h" + +TEST_CONSTEXPR_CXX14 bool test() { + const unsigned v = 0x12345678; + + ASSERT_SAME_TYPE(unsigned, decltype(std::__rotr(v, 3))); + ASSERT_SAME_TYPE(int, decltype(std::__countl_zero(v))); + + assert(std::__rotr(v, 3) == 0x02468acfU); + assert(std::__countl_zero(v) == 3); + + return true; +} + +int main(int, char**) { + test(); +#if TEST_STD_VER > 11 + static_assert(test(), ""); +#endif + + return 0; +} |
