blob: 420996759d0d7d6538fd48b3fccde8f7327e9f93 [file] [log] [blame]
Dan Albert287553d2017-02-16 10:47:51 -08001//===----------------------------------------------------------------------===//
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>& 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
20template <std::size_t N>
21std::bitset<N>
22make_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
30template <std::size_t N>
31void test_op_xor_eq()
32{
33 std::bitset<N> v1 = make_bitset<N>();
34 std::bitset<N> v2 = make_bitset<N>();
35 std::bitset<N> v3 = v1;
36 v1 ^= v2;
37 for (std::size_t i = 0; i < N; ++i)
38 assert(v1[i] == (v3[i] != v2[i]));
39}
40
41int main()
42{
43 test_op_xor_eq<0>();
44 test_op_xor_eq<1>();
45 test_op_xor_eq<31>();
46 test_op_xor_eq<32>();
47 test_op_xor_eq<33>();
48 test_op_xor_eq<63>();
49 test_op_xor_eq<64>();
50 test_op_xor_eq<65>();
51 test_op_xor_eq<1000>();
52}