brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 92e6496 Raw
54 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// bool test(size_t pos) const; // constexpr since C++2310 11#include <bitset>12#include <cassert>13#include <cstddef>14#include <vector>15 16#include "../bitset_test_cases.h"17#include "test_macros.h"18 19template <std::size_t N>20TEST_CONSTEXPR_CXX23 void test_test() {21    std::vector<std::bitset<N> > const cases = get_test_cases<N>();22    for (std::size_t c = 0; c != cases.size(); ++c) {23        std::bitset<N> const v = cases[c];24        if (v.size() > 0) {25            std::size_t middle = v.size() / 2;26            bool b = v.test(middle);27            assert(b == v[middle]);28        }29    }30}31 32TEST_CONSTEXPR_CXX23 bool test() {33  test_test<0>();34  test_test<1>();35  test_test<31>();36  test_test<32>();37  test_test<33>();38  test_test<63>();39  test_test<64>();40  test_test<65>();41 42  return true;43}44 45int main(int, char**) {46  test();47  test_test<1000>(); // not in constexpr because of constexpr evaluation step limits48#if TEST_STD_VER > 2049  static_assert(test());50#endif51 52  return 0;53}54