1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <system_error>
11
12 // bool operator==(const error_code& lhs, const error_code& rhs);
13 // bool operator==(const error_code& lhs, const error_condition& rhs);
14 // bool operator==(const error_condition& lhs, const error_code& rhs);
15 // bool operator==(const error_condition& lhs, const error_condition& rhs);
16 // bool operator!=(const error_code& lhs, const error_code& rhs);
17 // bool operator!=(const error_code& lhs, const error_condition& rhs);
18 // bool operator!=(const error_condition& lhs, const error_code& rhs);
19 // bool operator!=(const error_condition& lhs, const error_condition& rhs);
20
21 #include <system_error>
22 #include <cassert>
23
main()24 int main()
25 {
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 assert(e_code2 == e_condition1); // ?
49 assert(e_code2 == e_condition2);
50 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 assert(e_code4 != e_condition1);
67 assert(e_code4 != e_condition2);
68 assert(e_code4 == e_condition3); // ?
69 assert(e_code4 == e_condition4);
70
71 assert(e_condition1 == e_code1);
72 assert(e_condition1 == e_code2); // ?
73 assert(e_condition1 != e_code3);
74 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 assert(e_condition3 != e_code2);
91 assert(e_condition3 == e_code3);
92 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