]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/19_diagnostics/error_code/operators/three_way.cc
ce659d7ab527124e5a81e8fa4fc6337b7c891534
1 // Copyright (C) 2020-2023 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-options "-std=gnu++2a" }
19 // { dg-do run { target c++2a } }
21 #include <system_error>
22 #include <testsuite_error.h>
28 std::error_code
e2(std::make_error_code(std::errc::operation_not_supported
));
30 VERIFY( std::is_eq(e1
<=> e1
) );
31 VERIFY( std::is_lteq(e1
<=> e1
) );
32 VERIFY( std::is_gteq(e1
<=> e1
) );
34 VERIFY( std::is_neq(e1
<=> e2
) );
35 VERIFY( std::is_lt(e1
<=> e2
) || std::is_gt(e1
<=> e2
) );
36 VERIFY( (e1
<=> e2
) == (e1
.category() <=> e2
.category()) );
39 VERIFY( !(e1
== e2
) );
44 const __gnu_test::test_category cat
;
45 std::error_code
e3(e2
.value(), cat
);
47 VERIFY( std::is_neq(e2
<=> e3
) );
48 VERIFY( std::is_lt(e2
<=> e3
) || std::is_gt(e2
<=> e3
) );
49 VERIFY( (e2
<=> e3
) == (e2
.category() <=> e3
.category()) );
51 VERIFY( !(e2
== e3
) );
54 VERIFY( (e2
< e3
) == (e2
.category() < e3
.category()) );
56 std::error_code
e4(std::make_error_code(std::errc::invalid_argument
));
58 VERIFY( std::is_neq(e4
<=> e2
) );
59 VERIFY( std::is_lt(e4
<=> e2
) || std::is_gt(e4
<=> e2
) );
60 VERIFY( (e4
<=> e2
) == (e4
.value() <=> e2
.value()) );