ull_ctor.pass.cpp revision c52f43e72dfcea03037729649da84c23b3beb04a
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// test bitset(unsigned long long val);
11
12#include <bitset>
13#include <cassert>
14
15template <std::size_t N>
16void test_val_ctor()
17{
18    {
19    std::bitset<N> v(0xAAAAAAAAAAAAAAAAULL);
20    assert(v.size() == N);
21    unsigned M = std::min<std::size_t>(N, 64);
22    for (std::size_t i = 0; i < M; ++i)
23        assert(v[i] == (i & 1));
24    for (std::size_t i = M; i < N; ++i)
25        assert(v[i] == false);
26    }
27}
28
29int main()
30{
31    test_val_ctor<0>();
32    test_val_ctor<1>();
33    test_val_ctor<31>();
34    test_val_ctor<32>();
35    test_val_ctor<33>();
36    test_val_ctor<63>();
37    test_val_ctor<64>();
38    test_val_ctor<65>();
39    test_val_ctor<1000>();
40}
41