any.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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 bool any() const;
11
12#include <bitset>
13#include <cassert>
14
15template <std::size_t N>
16void test_any()
17{
18    std::bitset<N> v;
19    v.reset();
20    assert(v.any() == false);
21    v.set();
22    assert(v.any() == (N != 0));
23    if (N > 1)
24    {
25        v[N/2] = false;
26        assert(v.any() == true);
27        v.reset();
28        v[N/2] = true;
29        assert(v.any() == true);
30    }
31}
32
33int main()
34{
35    test_any<0>();
36    test_any<1>();
37    test_any<31>();
38    test_any<32>();
39    test_any<33>();
40    test_any<63>();
41    test_any<64>();
42    test_any<65>();
43    test_any<1000>();
44}
45