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 // XFAIL: libcpp-no-exceptions
11 // test bitset<N>& set(size_t pos, bool val = true);
12 
13 #include <bitset>
14 #include <cassert>
15 
16 template <std::size_t N>
17 void test_set_one()
18 {
19     std::bitset<N> v;
20     try
21     {
22         v.set(50);
23         if (50 >= v.size())
24             assert(false);
25         assert(v[50]);
26     }
27     catch (std::out_of_range&)
28     {
29     }
30     try
31     {
32         v.set(50, false);
33         if (50 >= v.size())
34             assert(false);
35         assert(!v[50]);
36     }
37     catch (std::out_of_range&)
38     {
39     }
40 }
41 
42 int main()
43 {
44     test_set_one<0>();
45     test_set_one<1>();
46     test_set_one<31>();
47     test_set_one<32>();
48     test_set_one<33>();
49     test_set_one<63>();
50     test_set_one<64>();
51     test_set_one<65>();
52     test_set_one<1000>();
53 }
54