brintos

brintos / llvm-project-archived public Read only

0
0
Text · 941 B · 1f20811 Raw
35 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// Test the __XXXX routines in the <bit> header.10// These are not supposed to be exhaustive tests, just sanity checks.11 12#include <__cxx03/__bit/countl.h>13#include <__cxx03/__bit/rotate.h>14#include <cassert>15 16#include "test_macros.h"17 18TEST_CONSTEXPR_CXX14 bool test() {19  const unsigned v = 0x12345678;20 21  ASSERT_SAME_TYPE(unsigned, decltype(std::__rotr(v, 3)));22  ASSERT_SAME_TYPE(int, decltype(std::__countl_zero(v)));23 24  assert(std::__rotr(v, 3) == 0x02468acfU);25  assert(std::__countl_zero(v) == 3);26 27  return true;28}29 30int main(int, char**) {31  test();32 33  return 0;34}35