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 #if defined(TEST_COMPILER_C1XX) 20 #pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed. 21 #endif 22 23 template <std::size_t N> test_val_ctor()24void test_val_ctor() 25 { 26 { 27 TEST_CONSTEXPR std::bitset<N> v(0xAAAAAAAAAAAAAAAAULL); 28 assert(v.size() == N); 29 std::size_t M = std::min<std::size_t>(N, 64); 30 for (std::size_t i = 0; i < M; ++i) 31 assert(v[i] == ((i & 1) != 0)); 32 for (std::size_t i = M; i < N; ++i) 33 assert(v[i] == false); 34 } 35 #if TEST_STD_VER >= 11 36 { 37 constexpr std::bitset<N> v(0xAAAAAAAAAAAAAAAAULL); 38 static_assert(v.size() == N, ""); 39 } 40 #endif 41 } 42 main()43int main() 44 { 45 test_val_ctor<0>(); 46 test_val_ctor<1>(); 47 test_val_ctor<31>(); 48 test_val_ctor<32>(); 49 test_val_ctor<33>(); 50 test_val_ctor<63>(); 51 test_val_ctor<64>(); 52 test_val_ctor<65>(); 53 test_val_ctor<1000>(); 54 } 55