brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 98b602d Raw
58 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:10 11// bool operator==(const bitset<N>& rhs) const; // constexpr since C++2312// bool operator!=(const bitset<N>& rhs) 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_equality() {24    std::vector<std::bitset<N> > const cases = get_test_cases<N>();25    for (std::size_t c = 0; c != cases.size(); ++c) {26        std::bitset<N> const v1 = cases[c];27        std::bitset<N> v2 = v1;28        assert(v1 == v2);29        if (v1.size() > 0) {30            v2[N/2].flip();31            assert(v1 != v2);32        }33    }34}35 36TEST_CONSTEXPR_CXX23 bool test() {37  test_equality<0>();38  test_equality<1>();39  test_equality<31>();40  test_equality<32>();41  test_equality<33>();42  test_equality<63>();43  test_equality<64>();44  test_equality<65>();45 46  return true;47}48 49int main(int, char**) {50  test();51  test_equality<1000>(); // not in constexpr because of constexpr evaluation step limits52#if TEST_STD_VER > 2053  static_assert(test());54#endif55 56  return 0;57}58