Home | History | Annotate | Download | only in bitset.cons
      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 #pragma clang diagnostic ignored "-Wtautological-compare"
     17 
     18 template <std::size_t N>
     19 void test_val_ctor()
     20 {
     21     {
     22     _LIBCPP_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 }
     31 
     32 int main()
     33 {
     34     test_val_ctor<0>();
     35     test_val_ctor<1>();
     36     test_val_ctor<31>();
     37     test_val_ctor<32>();
     38     test_val_ctor<33>();
     39     test_val_ctor<63>();
     40     test_val_ctor<64>();
     41     test_val_ctor<65>();
     42     test_val_ctor<1000>();
     43 }
     44