Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / libstdc++-v3 / testsuite / 23_containers / bitset / cons / 6282.cc
1 // 1999-06-08 bkoz
2
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.
10
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.
15
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/>.
19
20 // 23.3.5.1 bitset constructors
21
22 #include <string>
23 #include <bitset>
24 #include <stdexcept>
25 #include <testsuite_hooks.h>
26
27 // boundary condition:  a zero-sized set
28 // libstdc++/6282
29 bool test02(void)
30 {
31   using std::char_traits;  using std::allocator;
32   bool test __attribute__((unused)) = true;
33
34   std::bitset<0>  z1;
35   VERIFY( z1.any() == false );
36
37   std::bitset<0>  z2(12345);
38   VERIFY( z2.any() == false );
39
40   std::bitset<0>  z3(std::string("10101010101"));
41   VERIFY( z3.any() == false );
42
43   try {
44     z1.set(0);
45     VERIFY( false );
46   }
47   catch(std::out_of_range& fail) {
48     VERIFY( true );
49   }
50   catch(...) {
51     VERIFY( false );
52   }
53
54   VERIFY( z1.to_ulong() == 0 );
55   VERIFY( (z1.to_string<char,char_traits<char>,allocator<char> >().empty() ));
56   return test;
57 }
58
59 int main()
60 {
61   test02();
62   return 0;
63 }