1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <system_error>
10
11// bool operator==(const error_code& lhs, const error_code& rhs);
12// bool operator==(const error_code& lhs, const error_condition& rhs);
13// bool operator==(const error_condition& lhs, const error_code& rhs);
14// bool operator==(const error_condition& lhs, const error_condition& rhs);
15// bool operator!=(const error_code& lhs, const error_code& rhs);
16// bool operator!=(const error_code& lhs, const error_condition& rhs);
17// bool operator!=(const error_condition& lhs, const error_code& rhs);
18// bool operator!=(const error_condition& lhs, const error_condition& rhs);
19
20#include <system_error>
21#include <cassert>
22
23#include "test_macros.h"
24
25int main(int, char**) {
26 std::error_code e_code1(5, std::generic_category());
27 std::error_code e_code2(5, std::system_category());
28 std::error_code e_code3(6, std::generic_category());
29 std::error_code e_code4(6, std::system_category());
30 std::error_condition e_condition1(5, std::generic_category());
31 std::error_condition e_condition2(5, std::system_category());
32 std::error_condition e_condition3(6, std::generic_category());
33 std::error_condition e_condition4(6, std::system_category());
34
35 assert(e_code1 == e_code1);
36 assert(e_code1 != e_code2);
37 assert(e_code1 != e_code3);
38 assert(e_code1 != e_code4);
39 assert(e_code1 == e_condition1);
40 assert(e_code1 != e_condition2);
41 assert(e_code1 != e_condition3);
42 assert(e_code1 != e_condition4);
43
44 assert(e_code2 != e_code1);
45 assert(e_code2 == e_code2);
46 assert(e_code2 != e_code3);
47 assert(e_code2 != e_code4);
48 LIBCPP_ASSERT(e_code2 == e_condition1);
49 assert(e_code2 == e_condition2);
50 LIBCPP_ASSERT(e_code2 != e_condition3);
51 assert(e_code2 != e_condition4);
52
53 assert(e_code3 != e_code1);
54 assert(e_code3 != e_code2);
55 assert(e_code3 == e_code3);
56 assert(e_code3 != e_code4);
57 assert(e_code3 != e_condition1);
58 assert(e_code3 != e_condition2);
59 assert(e_code3 == e_condition3);
60 assert(e_code3 != e_condition4);
61
62 assert(e_code4 != e_code1);
63 assert(e_code4 != e_code2);
64 assert(e_code4 != e_code3);
65 assert(e_code4 == e_code4);
66 LIBCPP_ASSERT(e_code4 != e_condition1);
67 assert(e_code4 != e_condition2);
68 LIBCPP_ASSERT(e_code4 == e_condition3);
69 assert(e_code4 == e_condition4);
70
71 assert(e_condition1 == e_code1);
72 LIBCPP_ASSERT(e_condition1 == e_code2);
73 assert(e_condition1 != e_code3);
74 LIBCPP_ASSERT(e_condition1 != e_code4);
75 assert(e_condition1 == e_condition1);
76 assert(e_condition1 != e_condition2);
77 assert(e_condition1 != e_condition3);
78 assert(e_condition1 != e_condition4);
79
80 assert(e_condition2 != e_code1);
81 assert(e_condition2 == e_code2);
82 assert(e_condition2 != e_code3);
83 assert(e_condition2 != e_code4);
84 assert(e_condition2 != e_condition1);
85 assert(e_condition2 == e_condition2);
86 assert(e_condition2 != e_condition3);
87 assert(e_condition2 != e_condition4);
88
89 assert(e_condition3 != e_code1);
90 LIBCPP_ASSERT(e_condition3 != e_code2);
91 assert(e_condition3 == e_code3);
92 LIBCPP_ASSERT(e_condition3 == e_code4);
93 assert(e_condition3 != e_condition1);
94 assert(e_condition3 != e_condition2);
95 assert(e_condition3 == e_condition3);
96 assert(e_condition3 != e_condition4);
97
98 assert(e_condition4 != e_code1);
99 assert(e_condition4 != e_code2);
100 assert(e_condition4 != e_code3);
101 assert(e_condition4 == e_code4);
102 assert(e_condition4 != e_condition1);
103 assert(e_condition4 != e_condition2);
104 assert(e_condition4 != e_condition3);
105 assert(e_condition4 == e_condition4);
106
107 return 0;
108}
109

source code of libcxx/test/std/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp