]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/19_diagnostics/error_code/operators/three_way.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 19_diagnostics / error_code / operators / three_way.cc
1 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
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-options "-std=gnu++2a" }
19 // { dg-do run { target c++2a } }
20
21 #include <system_error>
22 #include <testsuite_error.h>
23
24 void
25 test01()
26 {
27 std::error_code e1;
28 std::error_code e2(std::make_error_code(std::errc::operation_not_supported));
29
30 VERIFY( std::is_eq(e1 <=> e1) );
31 VERIFY( std::is_lteq(e1 <=> e1) );
32 VERIFY( std::is_gteq(e1 <=> e1) );
33
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()) );
37
38 VERIFY( e1 == e1 );
39 VERIFY( !(e1 == e2) );
40
41 VERIFY( !(e1 < e1) );
42 VERIFY( !(e2 < e2) );
43
44 const __gnu_test::test_category cat;
45 std::error_code e3(e2.value(), cat);
46
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()) );
50
51 VERIFY( !(e2 == e3) );
52
53 VERIFY( !(e3 < e3) );
54 VERIFY( (e2 < e3) == (e2.category() < e3.category()) );
55
56 std::error_code e4(std::make_error_code(std::errc::invalid_argument));
57
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()) );
61 }
62
63 int main()
64 {
65 test01();
66 }