blob: 067f868215be91141f7cb4ebad447441403b8814 [file] [log] [blame]
Howard Hinnantc52f43e2010-08-22 00:59:46 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantc52f43e2010-08-22 00:59:46 +00007//
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
Howard Hinnant97ecd642011-05-17 19:12:55 +000016#pragma clang diagnostic ignored "-Wtautological-compare"
17
Howard Hinnantc52f43e2010-08-22 00:59:46 +000018template <std::size_t N>
19std::bitset<N>
20make_bitset()
21{
22 std::bitset<N> v;
23 for (std::size_t i = 0; i < N; ++i)
24 v[i] = static_cast<bool>(std::rand() & 1);
25 return v;
26}
27
28template <std::size_t N>
29void test_op_or()
30{
31 std::bitset<N> v1 = make_bitset<N>();
32 std::bitset<N> v2 = make_bitset<N>();
33 std::bitset<N> v3 = v1;
34 assert((v1 | v2) == (v3 |= v2));;
35}
36
37int main()
38{
39 test_op_or<0>();
40 test_op_or<1>();
41 test_op_or<31>();
42 test_op_or<32>();
43 test_op_or<33>();
44 test_op_or<63>();
45 test_op_or<64>();
46 test_op_or<65>();
47 test_op_or<1000>();
48}