xref: /minix3/external/bsd/libc++/dist/libcxx/test/utilities/template.bitset/bitset.members/all.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 all() 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_all()16*4684ddb6SLionel Sambuc void test_all()
17*4684ddb6SLionel Sambuc {
18*4684ddb6SLionel Sambuc     std::bitset<N> v;
19*4684ddb6SLionel Sambuc     v.reset();
20*4684ddb6SLionel Sambuc     assert(v.all() == (N == 0));
21*4684ddb6SLionel Sambuc     v.set();
22*4684ddb6SLionel Sambuc     assert(v.all() == true);
23*4684ddb6SLionel Sambuc     if (N > 1)
24*4684ddb6SLionel Sambuc     {
25*4684ddb6SLionel Sambuc         v[N/2] = false;
26*4684ddb6SLionel Sambuc         assert(v.all() == false);
27*4684ddb6SLionel Sambuc     }
28*4684ddb6SLionel Sambuc }
29*4684ddb6SLionel Sambuc 
main()30*4684ddb6SLionel Sambuc int main()
31*4684ddb6SLionel Sambuc {
32*4684ddb6SLionel Sambuc     test_all<0>();
33*4684ddb6SLionel Sambuc     test_all<1>();
34*4684ddb6SLionel Sambuc     test_all<31>();
35*4684ddb6SLionel Sambuc     test_all<32>();
36*4684ddb6SLionel Sambuc     test_all<33>();
37*4684ddb6SLionel Sambuc     test_all<63>();
38*4684ddb6SLionel Sambuc     test_all<64>();
39*4684ddb6SLionel Sambuc     test_all<65>();
40*4684ddb6SLionel Sambuc     test_all<1000>();
41*4684ddb6SLionel Sambuc }
42