]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / bitset / cons / 6282.cc
1 // 1999-06-08 bkoz
2
3 // Copyright (C) 1999-2020 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 void test02(void)
30 {
31 using std::char_traits; using std::allocator;
32
33 std::bitset<0> z1;
34 VERIFY( z1.any() == false );
35
36 std::bitset<0> z2(12345);
37 VERIFY( z2.any() == false );
38
39 std::bitset<0> z3(std::string("10101010101"));
40 VERIFY( z3.any() == false );
41
42 try {
43 z1.set(0);
44 VERIFY( false );
45 }
46 catch(std::out_of_range& fail) {
47 VERIFY( true );
48 }
49 catch(...) {
50 VERIFY( false );
51 }
52
53 VERIFY( z1.to_ulong() == 0 );
54 VERIFY( (z1.to_string<char,char_traits<char>,allocator<char> >().empty() ));
55 }
56
57 int main()
58 {
59 test02();
60 return 0;
61 }