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