brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · af4e4a8 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// bitset<N>& operator^=(const bitset<N>& rhs); // 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 bool test_op_xor_eq() {21    std::vector<std::bitset<N> > const cases = get_test_cases<N>();22    for (std::size_t c1 = 0; c1 != cases.size(); ++c1) {23        for (std::size_t c2 = 0; c2 != cases.size(); ++c2) {24            std::bitset<N> v1 = cases[c1];25            std::bitset<N> v2 = cases[c2];26            std::bitset<N> v3 = v1;27            v1 ^= v2;28            for (std::size_t i = 0; i < v1.size(); ++i)29                assert(v1[i] == (v3[i] != v2[i]));30        }31    }32    return true;33}34 35int main(int, char**) {36  test_op_xor_eq<0>();37  test_op_xor_eq<1>();38  test_op_xor_eq<31>();39  test_op_xor_eq<32>();40  test_op_xor_eq<33>();41  test_op_xor_eq<63>();42  test_op_xor_eq<64>();43  test_op_xor_eq<65>();44  test_op_xor_eq<1000>(); // not in constexpr because of constexpr evaluation step limits45#if TEST_STD_VER > 2046  static_assert(test_op_xor_eq<0>());47  static_assert(test_op_xor_eq<1>());48  static_assert(test_op_xor_eq<31>());49  static_assert(test_op_xor_eq<32>());50  static_assert(test_op_xor_eq<33>());51  static_assert(test_op_xor_eq<63>());52  static_assert(test_op_xor_eq<64>());53  static_assert(test_op_xor_eq<65>());54#endif55 56  return 0;57}58