]>
Commit | Line | Data |
---|---|---|
17472bb6 | 1 | // 1999-06-08 bkoz |
84b9f762 | 2 | |
a5544970 | 3 | // Copyright (C) 1999-2019 Free Software Foundation, Inc. |
84b9f762 BK |
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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
84b9f762 BK |
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 | |
748086b7 JJ |
17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
84b9f762 | 19 | |
17472bb6 | 20 | // 23.3.5.1 bitset constructors |
84b9f762 | 21 | |
17472bb6 | 22 | #include <string> |
84b9f762 | 23 | #include <bitset> |
8dba028f | 24 | #include <stdexcept> |
fe413112 | 25 | #include <testsuite_hooks.h> |
84b9f762 | 26 | |
17472bb6 BK |
27 | // boundary condition: a zero-sized set |
28 | // libstdc++/6282 | |
a9260b7e | 29 | void test02(void) |
84b9f762 | 30 | { |
17472bb6 | 31 | using std::char_traits; using std::allocator; |
84b9f762 | 32 | |
17472bb6 BK |
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 | ||
84b9f762 | 42 | try { |
17472bb6 | 43 | z1.set(0); |
84b9f762 BK |
44 | VERIFY( false ); |
45 | } | |
46 | catch(std::out_of_range& fail) { | |
47 | VERIFY( true ); | |
48 | } | |
49 | catch(...) { | |
50 | VERIFY( false ); | |
51 | } | |
3bbfb3d9 | 52 | |
17472bb6 BK |
53 | VERIFY( z1.to_ulong() == 0 ); |
54 | VERIFY( (z1.to_string<char,char_traits<char>,allocator<char> >().empty() )); | |
3bbfb3d9 PE |
55 | } |
56 | ||
84b9f762 BK |
57 | int main() |
58 | { | |
1cb7f91f | 59 | test02(); |
84b9f762 BK |
60 | return 0; |
61 | } |