1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // test bitset<N>& flip(size_t pos);
16 #include "test_macros.h"
18 #if defined(TEST_COMPILER_C1XX)
19 #pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed.
22 template <std::size_t N>
27 for (std::size_t i = 0; i < N; ++i)
28 v[i] = static_cast<bool>(std::rand() & 1);
32 template <std::size_t N>
33 void test_flip_one(bool test_throws)
35 std::bitset<N> v = make_bitset<N>();
36 #ifdef TEST_HAS_NO_EXCEPTIONS
37 if (test_throws) return;
52 #ifndef TEST_HAS_NO_EXCEPTIONS
54 catch (std::out_of_range&)
63 test_flip_one<0>(true);
64 test_flip_one<1>(true);
65 test_flip_one<31>(true);
66 test_flip_one<32>(true);
67 test_flip_one<33>(true);
68 test_flip_one<63>(false);
69 test_flip_one<64>(false);
70 test_flip_one<65>(false);
71 test_flip_one<1000>(false);