]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/19_diagnostics/error_category/generic_category.cc
1 // Copyright (C) 2018-2020 Free Software Foundation, Inc.
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)
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.
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/>.
18 // { dg-do run { target c++11 } }
20 #include <system_error>
22 #include <testsuite_hooks.h>
27 const char* name
= std::generic_category().name();
28 VERIFY( name
== std::string("generic") );
34 const std::error_category
& cat
= std::generic_category();
35 std::error_condition cond
;
37 cond
= cat
.default_error_condition(EBADF
);
38 VERIFY( cond
.value() == EBADF
);
39 VERIFY( cond
== std::errc::bad_file_descriptor
);
40 VERIFY( cond
.category() == std::generic_category() );
41 cond
= cat
.default_error_condition(EACCES
);
42 VERIFY( cond
.value() == EACCES
);
43 VERIFY( cond
== std::errc::permission_denied
);
44 VERIFY( cond
.category() == std::generic_category() );
47 VERIFY( std::error_code(EBADF
, cat
) == std::errc::bad_file_descriptor
);
48 VERIFY( std::error_code(EACCES
, cat
) == std::errc::permission_denied
);
54 // set "C" locale to get expected message
55 auto loc
= std::locale::global(std::locale::classic());
57 std::string msg
= std::generic_category().message(EBADF
);
58 VERIFY( msg
.find("file") != std::string::npos
);
60 std::locale::global(loc
);