]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/ios_base/failure/cxx11.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / ios_base / failure / cxx11.cc
CommitLineData
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
23using test_type = std::ios_base::failure;
24
f997b675 25#if _GLIBCXX_USE_CXX11_ABI
a5dde6dd 26static_assert( std::is_base_of<std::system_error, test_type>::value, "base" );
f997b675 27#endif
a5dde6dd
JW
28
29void
30test01()
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
37struct E : test_type
38{
39 E(const char* s) : test_type(s, make_error_code(std::io_errc::stream)) { }
40};
41
42void
43test02()
44{
45 E e("io error");
46 VERIFY(std::string(e.what()).find("io error") != std::string::npos);
47}
48
49int
50main()
51{
52 test01();
53 test02();
54}