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 bitset(unsigned long long val);
11 
12 #include <bitset>
13 #include <cassert>
14 #include <algorithm> // for 'min' and 'max'
15 
16 #if defined(__clang__)
17 #pragma clang diagnostic ignored "-Wtautological-compare"
18 #endif
19 
20 template <std::size_t N>
21 void test_val_ctor()
22 {
23     {
24     _LIBCPP_CONSTEXPR std::bitset<N> v(0xAAAAAAAAAAAAAAAAULL);
25     assert(v.size() == N);
26     unsigned M = std::min<std::size_t>(N, 64);
27     for (std::size_t i = 0; i < M; ++i)
28         assert(v[i] == (i & 1));
29     for (std::size_t i = M; i < N; ++i)
30         assert(v[i] == false);
31     }
32 }
33 
34 int main()
35 {
36     test_val_ctor<0>();
37     test_val_ctor<1>();
38     test_val_ctor<31>();
39     test_val_ctor<32>();
40     test_val_ctor<33>();
41     test_val_ctor<63>();
42     test_val_ctor<64>();
43     test_val_ctor<65>();
44     test_val_ctor<1000>();
45 }
46