]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* Boost test/cmp.cpp |
2 | * test standard comparison functions | |
3 | * | |
4 | * Copyright 2002-2003 Guillaume Melquiond | |
5 | * | |
6 | * Distributed under the Boost Software License, Version 1.0. | |
7 | * (See accompanying file LICENSE_1_0.txt or | |
8 | * copy at http://www.boost.org/LICENSE_1_0.txt) | |
9 | */ | |
10 | ||
11 | #include "cmp_header.hpp" | |
12 | ||
13 | // comparisons between [1,2] and [3,4] | |
14 | ||
15 | static void test_12_34() { | |
16 | const I a(1,2), b(3,4); | |
17 | ||
18 | BOOST_CHECK(a < b); | |
19 | BOOST_CHECK(a <= b); | |
20 | BOOST_CHECK(!(a > b)); | |
21 | BOOST_CHECK(!(a >= b)); | |
22 | ||
23 | BOOST_CHECK(b > a); | |
24 | BOOST_CHECK(b >= a); | |
25 | BOOST_CHECK(!(b < a)); | |
26 | BOOST_CHECK(!(b <= a)); | |
27 | ||
28 | BOOST_CHECK(!(a == b)); | |
29 | BOOST_CHECK(a != b); | |
30 | ||
20effc67 | 31 | # ifdef BOOST_BORLANDC |
7c673cae FG |
32 | ::detail::ignore_unused_variable_warning(a); |
33 | ::detail::ignore_unused_variable_warning(b); | |
34 | # endif | |
35 | } | |
36 | ||
37 | // comparisons between [1,3] and [2,4] | |
38 | ||
39 | static void test_13_24() { | |
40 | const I a(1,3), b(2,4); | |
41 | ||
42 | BOOST_C_EXN(a < b); | |
43 | BOOST_C_EXN(a <= b); | |
44 | BOOST_C_EXN(a > b); | |
45 | BOOST_C_EXN(a >= b); | |
46 | ||
47 | BOOST_C_EXN(b < a); | |
48 | BOOST_C_EXN(b <= a); | |
49 | BOOST_C_EXN(b > a); | |
50 | BOOST_C_EXN(b >= a); | |
51 | ||
52 | BOOST_C_EXN(a == b); | |
53 | BOOST_C_EXN(a != b); | |
54 | ||
20effc67 | 55 | # ifdef BOOST_BORLANDC |
7c673cae FG |
56 | ::detail::ignore_unused_variable_warning(a); |
57 | ::detail::ignore_unused_variable_warning(b); | |
58 | # endif | |
59 | } | |
60 | ||
61 | // comparisons between [1,2] and [2,3] | |
62 | ||
63 | static void test_12_23() { | |
64 | const I a(1,2), b(2,3); | |
65 | ||
66 | BOOST_C_EXN(a < b); | |
67 | BOOST_CHECK(a <= b); | |
68 | BOOST_CHECK(!(a > b)); | |
69 | BOOST_C_EXN(a >= b); | |
70 | ||
71 | BOOST_CHECK(!(b < a)); | |
72 | BOOST_C_EXN(b <= a); | |
73 | BOOST_C_EXN(b > a); | |
74 | BOOST_CHECK(b >= a); | |
75 | ||
76 | BOOST_C_EXN(a == b); | |
77 | BOOST_C_EXN(a != b); | |
78 | ||
20effc67 | 79 | # ifdef BOOST_BORLANDC |
7c673cae FG |
80 | ::detail::ignore_unused_variable_warning(a); |
81 | ::detail::ignore_unused_variable_warning(b); | |
82 | # endif | |
83 | } | |
84 | ||
85 | // comparisons between [1,2] and 0 | |
86 | ||
87 | static void test_12_0() { | |
88 | const I a(1,2); | |
89 | const int b = 0; | |
90 | ||
91 | BOOST_CHECK(!(a < b)); | |
92 | BOOST_CHECK(!(a <= b)); | |
93 | BOOST_CHECK(a > b); | |
94 | BOOST_CHECK(a >= b); | |
95 | ||
96 | BOOST_CHECK(!(a == b)); | |
97 | BOOST_CHECK(a != b); | |
98 | ||
20effc67 | 99 | # ifdef BOOST_BORLANDC |
7c673cae FG |
100 | ::detail::ignore_unused_variable_warning(a); |
101 | ::detail::ignore_unused_variable_warning(b); | |
102 | # endif | |
103 | } | |
104 | ||
105 | // comparisons between [1,2] and 1 | |
106 | ||
107 | static void test_12_1() { | |
108 | const I a(1,2); | |
109 | const int b = 1; | |
110 | ||
111 | BOOST_CHECK(!(a < b)); | |
112 | BOOST_C_EXN(a <= b); | |
113 | BOOST_C_EXN(a > b); | |
114 | BOOST_CHECK(a >= b); | |
115 | ||
116 | BOOST_C_EXN(a == b); | |
117 | BOOST_C_EXN(a != b); | |
118 | ||
20effc67 | 119 | # ifdef BOOST_BORLANDC |
7c673cae FG |
120 | ::detail::ignore_unused_variable_warning(a); |
121 | ::detail::ignore_unused_variable_warning(b); | |
122 | # endif | |
123 | } | |
124 | ||
125 | // comparisons between [1,2] and 2 | |
126 | ||
127 | static void test_12_2() { | |
128 | const I a(1,2); | |
129 | const int b = 2; | |
130 | ||
131 | BOOST_C_EXN(a < b); | |
132 | BOOST_CHECK(a <= b); | |
133 | BOOST_CHECK(!(a > b)); | |
134 | BOOST_C_EXN(a >= b); | |
135 | ||
136 | BOOST_C_EXN(a == b); | |
137 | BOOST_C_EXN(a != b); | |
138 | ||
20effc67 | 139 | # ifdef BOOST_BORLANDC |
7c673cae FG |
140 | ::detail::ignore_unused_variable_warning(a); |
141 | ::detail::ignore_unused_variable_warning(b); | |
142 | # endif | |
143 | } | |
144 | ||
145 | // comparisons between [1,2] and 3 | |
146 | ||
147 | static void test_12_3() { | |
148 | const I a(1,2); | |
149 | const int b = 3; | |
150 | ||
151 | BOOST_CHECK(a < b); | |
152 | BOOST_CHECK(a <= b); | |
153 | BOOST_CHECK(!(a > b)); | |
154 | BOOST_CHECK(!(a >= b)); | |
155 | ||
156 | BOOST_CHECK(!(a == b)); | |
157 | BOOST_CHECK(a != b); | |
158 | ||
20effc67 | 159 | # ifdef BOOST_BORLANDC |
7c673cae FG |
160 | ::detail::ignore_unused_variable_warning(a); |
161 | ::detail::ignore_unused_variable_warning(b); | |
162 | # endif | |
163 | } | |
164 | ||
165 | // comparisons between [1,2] and [1,2] | |
166 | ||
167 | static void test_12_12() { | |
168 | const I a(1,2), b(1,2); | |
169 | BOOST_C_EXN(a == b); | |
170 | BOOST_C_EXN(a != b); | |
20effc67 | 171 | # ifdef BOOST_BORLANDC |
7c673cae FG |
172 | ::detail::ignore_unused_variable_warning(a); |
173 | ::detail::ignore_unused_variable_warning(b); | |
174 | # endif | |
175 | } | |
176 | ||
177 | // comparisons between [1,1] and [1,1] | |
178 | ||
179 | static void test_11_11() { | |
180 | const I a(1,1), b(1,1); | |
181 | BOOST_CHECK(a == b); | |
182 | BOOST_CHECK(!(a != b)); | |
20effc67 | 183 | # ifdef BOOST_BORLANDC |
7c673cae FG |
184 | ::detail::ignore_unused_variable_warning(a); |
185 | ::detail::ignore_unused_variable_warning(b); | |
186 | # endif | |
187 | } | |
188 | ||
189 | // comparisons between [1,1] and 1 | |
190 | ||
191 | static void test_11_1() { | |
192 | const I a(1,1); | |
193 | const int b = 1; | |
194 | BOOST_CHECK(a == b); | |
195 | BOOST_CHECK(!(a != b)); | |
20effc67 | 196 | # ifdef BOOST_BORLANDC |
7c673cae FG |
197 | ::detail::ignore_unused_variable_warning(a); |
198 | ::detail::ignore_unused_variable_warning(b); | |
199 | # endif | |
200 | } | |
201 | ||
202 | int test_main(int, char *[]) { | |
203 | test_12_34(); | |
204 | test_13_24(); | |
205 | test_12_23(); | |
206 | test_12_0(); | |
207 | test_12_1(); | |
208 | test_12_2(); | |
209 | test_12_3(); | |
210 | test_12_12(); | |
211 | test_11_11(); | |
212 | test_11_1(); | |
213 | ||
214 | return 0; | |
215 | } |