]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / utilities / template.bitset / bitset.cons / ull_ctor.pass.cpp
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 #include <cstddef>
16
17 #include "test_macros.h"
18
19 template <std::size_t N>
20 void test_val_ctor()
21 {
22     {
23         TEST_CONSTEXPR std::bitset<N> v(0xAAAAAAAAAAAAAAAAULL);
24         assert(v.size() == N);
25         std::size_t M = std::min<std::size_t>(N, 64);
26         for (std::size_t i = 0; i < M; ++i)
27             assert(v[i] == ((i & 1) != 0));
28         for (std::size_t i = M; i < N; ++i)
29             assert(v[i] == false);
30     }
31 #if TEST_STD_VER >= 11
32     {
33         constexpr std::bitset<N> v(0xAAAAAAAAAAAAAAAAULL);
34         static_assert(v.size() == N, "");
35     }
36 #endif
37 }
38
39 int main()
40 {
41     test_val_ctor<0>();
42     test_val_ctor<1>();
43     test_val_ctor<31>();
44     test_val_ctor<32>();
45     test_val_ctor<33>();
46     test_val_ctor<63>();
47     test_val_ctor<64>();
48     test_val_ctor<65>();
49     test_val_ctor<1000>();
50 }