]>
Commit | Line | Data |
---|---|---|
cfc45d90 PC |
1 | // Copyright (C) 2004 Free Software Foundation, Inc. |
2 | // | |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 2, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING. If not, write to the Free | |
83f51799 | 16 | // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
cfc45d90 PC |
17 | // USA. |
18 | ||
19 | #include <istream> | |
20 | #include <streambuf> | |
21 | #include <testsuite_hooks.h> | |
22 | #include <testsuite_io.h> | |
23 | ||
24 | // libstdc++/9561 | |
25 | void test01() | |
26 | { | |
27 | using namespace std; | |
28 | bool test __attribute__((unused)) = true; | |
29 | ||
30 | __gnu_test::fail_wstreambuf b; | |
31 | std::wistream strm (&b); | |
32 | strm.exceptions (std::wios::badbit); | |
33 | wchar_t i = 0; | |
34 | ||
35 | try | |
36 | { | |
37 | i = strm.get(); | |
38 | i = strm.get(); | |
39 | i = strm.get(); | |
40 | } | |
41 | catch (__gnu_test::underflow_error&) | |
42 | { | |
43 | // strm should throw facet_error and not do anything else | |
44 | VERIFY(strm.bad()); | |
45 | } | |
46 | catch (...) | |
47 | { | |
48 | VERIFY( false ); | |
49 | } | |
50 | ||
51 | VERIFY( i == L's' ); | |
52 | } | |
53 | ||
54 | ||
55 | int main() | |
56 | { | |
57 | test01(); | |
58 | return 0; | |
59 | } |