xref: /minix3/external/bsd/libc++/dist/libcxx/test/utilities/template.bitset/bitset.members/any.pass.cpp (revision 4684ddb6aab0b36791c8099bc705d6140b3d05d0)
1*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
2*4684ddb6SLionel Sambuc //
3*4684ddb6SLionel Sambuc //                     The LLVM Compiler Infrastructure
4*4684ddb6SLionel Sambuc //
5*4684ddb6SLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open
6*4684ddb6SLionel Sambuc // Source Licenses. See LICENSE.TXT for details.
7*4684ddb6SLionel Sambuc //
8*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
9*4684ddb6SLionel Sambuc 
10*4684ddb6SLionel Sambuc // test bool any() const;
11*4684ddb6SLionel Sambuc 
12*4684ddb6SLionel Sambuc #include <bitset>
13*4684ddb6SLionel Sambuc #include <cassert>
14*4684ddb6SLionel Sambuc 
15*4684ddb6SLionel Sambuc template <std::size_t N>
test_any()16*4684ddb6SLionel Sambuc void test_any()
17*4684ddb6SLionel Sambuc {
18*4684ddb6SLionel Sambuc     std::bitset<N> v;
19*4684ddb6SLionel Sambuc     v.reset();
20*4684ddb6SLionel Sambuc     assert(v.any() == false);
21*4684ddb6SLionel Sambuc     v.set();
22*4684ddb6SLionel Sambuc     assert(v.any() == (N != 0));
23*4684ddb6SLionel Sambuc     if (N > 1)
24*4684ddb6SLionel Sambuc     {
25*4684ddb6SLionel Sambuc         v[N/2] = false;
26*4684ddb6SLionel Sambuc         assert(v.any() == true);
27*4684ddb6SLionel Sambuc         v.reset();
28*4684ddb6SLionel Sambuc         v[N/2] = true;
29*4684ddb6SLionel Sambuc         assert(v.any() == true);
30*4684ddb6SLionel Sambuc     }
31*4684ddb6SLionel Sambuc }
32*4684ddb6SLionel Sambuc 
main()33*4684ddb6SLionel Sambuc int main()
34*4684ddb6SLionel Sambuc {
35*4684ddb6SLionel Sambuc     test_any<0>();
36*4684ddb6SLionel Sambuc     test_any<1>();
37*4684ddb6SLionel Sambuc     test_any<31>();
38*4684ddb6SLionel Sambuc     test_any<32>();
39*4684ddb6SLionel Sambuc     test_any<33>();
40*4684ddb6SLionel Sambuc     test_any<63>();
41*4684ddb6SLionel Sambuc     test_any<64>();
42*4684ddb6SLionel Sambuc     test_any<65>();
43*4684ddb6SLionel Sambuc     test_any<1000>();
44*4684ddb6SLionel Sambuc }
45