]>
Commit | Line | Data |
---|---|---|
99dee823 | 1 | // Copyright (C) 2019-2021 Free Software Foundation, Inc. |
99f12959 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 | ||
18 | // { dg-do run { target c++11 } } | |
19 | ||
20 | #include <system_error> | |
21 | #include <testsuite_hooks.h> | |
22 | ||
23 | struct error_cat : std::error_category | |
24 | { | |
25 | error_cat(std::string s) : _name(s) { } | |
26 | std::string _name; | |
27 | const char* name() const noexcept override { return _name.c_str(); } | |
28 | std::string message(int) const override { return "error"; } | |
29 | }; | |
30 | ||
31 | void | |
32 | test01() | |
33 | { | |
34 | std::hash<std::error_code> h; | |
35 | error_cat kitty("kitty"), moggy("moggy"); | |
36 | std::error_code cond1(99, kitty); | |
37 | VERIFY( h(cond1) == h(cond1) ); | |
38 | std::error_code cond2(99, kitty); | |
39 | VERIFY( h(cond1) == h(cond2) ); | |
40 | std::error_code cond3(88, kitty); | |
41 | VERIFY( h(cond1) != h(cond3) ); | |
42 | std::error_code cond4(99, moggy); | |
43 | VERIFY( h(cond1) != h(cond4) ); | |
44 | } | |
45 | ||
46 | int | |
47 | main() | |
48 | { | |
49 | test01(); | |
50 | } |