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 #include "test_macros.h"
17 
18 template <std::size_t N>
19 void test_val_ctor()
20 {
21     {
22         TEST_CONSTEXPR std::bitset<N> v(0xAAAAAAAAAAAAAAAAULL);
23         assert(v.size() == N);
24         unsigned M = std::min<std::size_t>(N, 64);
25         for (std::size_t i = 0; i < M; ++i)
26             assert(v[i] == (i & 1));
27         for (std::size_t i = M; i < N; ++i)
28             assert(v[i] == false);
29     }
30 #if TEST_STD_VER >= 11
31     {
32         constexpr std::bitset<N> v(0xAAAAAAAAAAAAAAAAULL);
33         static_assert(v.size() == N, "");
34     }
35 #endif
36 }
37 
38 int main()
39 {
40     test_val_ctor<0>();
41     test_val_ctor<1>();
42     test_val_ctor<31>();
43     test_val_ctor<32>();
44     test_val_ctor<33>();
45     test_val_ctor<63>();
46     test_val_ctor<64>();
47     test_val_ctor<65>();
48     test_val_ctor<1000>();
49 }
50