brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 68ef5a6 Raw
56 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// The CI "Apple back-deployment with assertions enabled" needs a higher value10// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=1271242011 12// bitset<N> operator<<(size_t pos) const; // constexpr since C++2313 14#include <bitset>15#include <cassert>16#include <cstddef>17#include <vector>18 19#include "../bitset_test_cases.h"20#include "test_macros.h"21 22template <std::size_t N>23TEST_CONSTEXPR_CXX23 void test_left_shift() {24    std::vector<std::bitset<N> > const cases = get_test_cases<N>();25    for (std::size_t c = 0; c != cases.size(); ++c) {26        for (std::size_t s = 0; s <= N+1; ++s) {27            std::bitset<N> v1 = cases[c];28            std::bitset<N> v2 = v1;29            assert((v1 <<= s) == (v2 << s));30        }31    }32}33 34TEST_CONSTEXPR_CXX23 bool test() {35  test_left_shift<0>();36  test_left_shift<1>();37  test_left_shift<31>();38  test_left_shift<32>();39  test_left_shift<33>();40  test_left_shift<63>();41  test_left_shift<64>();42  test_left_shift<65>();43 44  return true;45}46 47int main(int, char**) {48  test();49  test_left_shift<1000>(); // not in constexpr because of constexpr evaluation step limits50#if TEST_STD_VER > 2051  static_assert(test());52#endif53 54  return 0;55}56