]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/utilities/template.bitset/bitset.operators/op_or.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / utilities / template.bitset / bitset.operators / op_or.pass.cpp
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // test bitset<N> operator|(const bitset<N>& lhs, const bitset<N>& rhs);
11
12 #include <bitset>
13 #include <cstdlib>
14 #include <cassert>
15
16 #if defined(__clang__)
17 #pragma clang diagnostic ignored "-Wtautological-compare"
18 #endif
19
20 template <std::size_t N>
21 std::bitset<N>
22 make_bitset()
23 {
24     std::bitset<N> v;
25     for (std::size_t i = 0; i < N; ++i)
26         v[i] = static_cast<bool>(std::rand() & 1);
27     return v;
28 }
29
30 template <std::size_t N>
31 void test_op_or()
32 {
33     std::bitset<N> v1 = make_bitset<N>();
34     std::bitset<N> v2 = make_bitset<N>();
35     std::bitset<N> v3 = v1;
36     assert((v1 | v2) == (v3 |= v2));
37 }
38
39 int main()
40 {
41     test_op_or<0>();
42     test_op_or<1>();
43     test_op_or<31>();
44     test_op_or<32>();
45     test_op_or<33>();
46     test_op_or<63>();
47     test_op_or<64>();
48     test_op_or<65>();
49     test_op_or<1000>();
50 }