Reverting merge from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / 23_containers / bitset / cons / 6282.cc
blob96dcc63c2bd2d8b95d36c2a008c75a70fa9187fa
1 // 1999-06-08 bkoz
3 // Copyright (C) 1999-2013 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 23.3.5.1 bitset constructors
22 #include <string>
23 #include <bitset>
24 #include <stdexcept>
25 #include <testsuite_hooks.h>
27 // boundary condition: a zero-sized set
28 // libstdc++/6282
29 bool test02(void)
31 using std::char_traits; using std::allocator;
32 bool test __attribute__((unused)) = true;
34 std::bitset<0> z1;
35 VERIFY( z1.any() == false );
37 std::bitset<0> z2(12345);
38 VERIFY( z2.any() == false );
40 std::bitset<0> z3(std::string("10101010101"));
41 VERIFY( z3.any() == false );
43 try {
44 z1.set(0);
45 VERIFY( false );
47 catch(std::out_of_range& fail) {
48 VERIFY( true );
50 catch(...) {
51 VERIFY( false );
54 VERIFY( z1.to_ulong() == 0 );
55 VERIFY( (z1.to_string<char,char_traits<char>,allocator<char> >().empty() ));
56 return test;
59 int main()
61 test02();
62 return 0;