]>
Commit | Line | Data |
---|---|---|
83ffe9cd | 1 | // Copyright (C) 2014-2023 Free Software Foundation, Inc. |
a5dde6dd JW |
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 3, 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 COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
52066eae | 18 | // { dg-do run { target c++11 } } |
a5dde6dd JW |
19 | |
20 | #include <ios> | |
21 | #include <testsuite_hooks.h> | |
22 | ||
23 | using test_type = std::ios_base::failure; | |
24 | ||
f997b675 | 25 | #if _GLIBCXX_USE_CXX11_ABI |
a5dde6dd | 26 | static_assert( std::is_base_of<std::system_error, test_type>::value, "base" ); |
f997b675 | 27 | #endif |
a5dde6dd JW |
28 | |
29 | void | |
30 | test01() | |
31 | { | |
32 | test_type e("io error"); | |
33 | VERIFY(std::string(e.what()).find("io error") != std::string::npos); | |
34 | e = test_type("", make_error_code(std::io_errc::stream)); | |
35 | } | |
36 | ||
37 | struct E : test_type | |
38 | { | |
39 | E(const char* s) : test_type(s, make_error_code(std::io_errc::stream)) { } | |
40 | }; | |
41 | ||
42 | void | |
43 | test02() | |
44 | { | |
45 | E e("io error"); | |
46 | VERIFY(std::string(e.what()).find("io error") != std::string::npos); | |
47 | } | |
48 | ||
49 | int | |
50 | main() | |
51 | { | |
52 | test01(); | |
53 | test02(); | |
54 | } |