Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / template.bitset / bitset.members / op_eq_eq.pass.cpp
blob98b602de90a09a316cedb27a4d77976fb8ecdc2e
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // test:
11 // bool operator==(const bitset<N>& rhs) const; // constexpr since C++23
12 // bool operator!=(const bitset<N>& rhs) const; // constexpr since C++23
14 #include <bitset>
15 #include <cassert>
16 #include <cstddef>
17 #include <vector>
19 #include "../bitset_test_cases.h"
20 #include "test_macros.h"
22 template <std::size_t N>
23 TEST_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);
36 TEST_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>();
46 return true;
49 int main(int, char**) {
50 test();
51 test_equality<1000>(); // not in constexpr because of constexpr evaluation step limits
52 #if TEST_STD_VER > 20
53 static_assert(test());
54 #endif
56 return 0;