1 | /* Boost test/cmp_set.cpp |
---|
2 | * test compare::set |
---|
3 | * |
---|
4 | * Copyright 2004 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::set; |
---|
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,4] and [2,3] |
---|
64 | |
---|
65 | static void test_14_23() { |
---|
66 | const I a(1,4), 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 [2,3] |
---|
88 | |
---|
89 | static void test_12_23() { |
---|
90 | const I a(1,2), b(2,3); |
---|
91 | |
---|
92 | BOOST_CHECK(!(a < b)); |
---|
93 | BOOST_CHECK(!(a <= b)); |
---|
94 | BOOST_CHECK(!(a > b)); |
---|
95 | BOOST_CHECK(!(a >= b)); |
---|
96 | |
---|
97 | BOOST_CHECK(!(b < a)); |
---|
98 | BOOST_CHECK(!(b <= a)); |
---|
99 | BOOST_CHECK(!(b > a)); |
---|
100 | BOOST_CHECK(!(b >= a)); |
---|
101 | |
---|
102 | BOOST_CHECK(!(a == b)); |
---|
103 | BOOST_CHECK(a != b); |
---|
104 | |
---|
105 | # ifdef __BORLANDC__ |
---|
106 | ::detail::ignore_unused_variable_warning(a); |
---|
107 | ::detail::ignore_unused_variable_warning(b); |
---|
108 | # endif |
---|
109 | } |
---|
110 | |
---|
111 | // comparisons between [1,2] and empty set |
---|
112 | |
---|
113 | static void test_12_E() { |
---|
114 | I a(1, 2), b(I::empty()); |
---|
115 | |
---|
116 | BOOST_CHECK(!(a < b)); |
---|
117 | BOOST_CHECK(!(a <= b)); |
---|
118 | BOOST_CHECK(a > b); |
---|
119 | BOOST_CHECK(a >= b); |
---|
120 | |
---|
121 | BOOST_CHECK(b < a); |
---|
122 | BOOST_CHECK(b <= a); |
---|
123 | BOOST_CHECK(!(b > a)); |
---|
124 | BOOST_CHECK(!(b >= a)); |
---|
125 | |
---|
126 | BOOST_CHECK(!(a == b)); |
---|
127 | BOOST_CHECK(a != b); |
---|
128 | |
---|
129 | # ifdef __BORLANDC__ |
---|
130 | ::detail::ignore_unused_variable_warning(a); |
---|
131 | ::detail::ignore_unused_variable_warning(b); |
---|
132 | # endif |
---|
133 | } |
---|
134 | |
---|
135 | // comparisons between two empty sets |
---|
136 | |
---|
137 | static void test_E_E() { |
---|
138 | I a(I::empty()), b(I::empty()); |
---|
139 | |
---|
140 | BOOST_CHECK(!(a < b)); |
---|
141 | BOOST_CHECK(a <= b); |
---|
142 | BOOST_CHECK(!(a > b)); |
---|
143 | BOOST_CHECK(a >= b); |
---|
144 | |
---|
145 | BOOST_CHECK(!(b < a)); |
---|
146 | BOOST_CHECK(b <= a); |
---|
147 | BOOST_CHECK(!(b > a)); |
---|
148 | BOOST_CHECK(b >= a); |
---|
149 | |
---|
150 | BOOST_CHECK(a == b); |
---|
151 | BOOST_CHECK(!(a != b)); |
---|
152 | |
---|
153 | # ifdef __BORLANDC__ |
---|
154 | ::detail::ignore_unused_variable_warning(a); |
---|
155 | ::detail::ignore_unused_variable_warning(b); |
---|
156 | # endif |
---|
157 | } |
---|
158 | |
---|
159 | // comparisons between [1,2] and [1,2] |
---|
160 | |
---|
161 | static void test_12_12() { |
---|
162 | const I a(1,2), b(1,2); |
---|
163 | |
---|
164 | BOOST_CHECK(!(a < b)); |
---|
165 | BOOST_CHECK(a <= b); |
---|
166 | BOOST_CHECK(!(a > b)); |
---|
167 | BOOST_CHECK(a >= b); |
---|
168 | |
---|
169 | BOOST_CHECK(!(b < a)); |
---|
170 | BOOST_CHECK(b <= a); |
---|
171 | BOOST_CHECK(!(b > a)); |
---|
172 | BOOST_CHECK(b >= a); |
---|
173 | |
---|
174 | BOOST_CHECK(a == b); |
---|
175 | BOOST_CHECK(!(a != b)); |
---|
176 | |
---|
177 | # ifdef __BORLANDC__ |
---|
178 | ::detail::ignore_unused_variable_warning(a); |
---|
179 | ::detail::ignore_unused_variable_warning(b); |
---|
180 | # endif |
---|
181 | } |
---|
182 | |
---|
183 | // comparisons between [1,1] and [1,1] |
---|
184 | |
---|
185 | static void test_11_11() { |
---|
186 | const I a(1,1), b(1,1); |
---|
187 | |
---|
188 | BOOST_CHECK(!(a < b)); |
---|
189 | BOOST_CHECK(a <= b); |
---|
190 | BOOST_CHECK(!(a > b)); |
---|
191 | BOOST_CHECK(a >= b); |
---|
192 | |
---|
193 | BOOST_CHECK(!(b < a)); |
---|
194 | BOOST_CHECK(b <= a); |
---|
195 | BOOST_CHECK(!(b > a)); |
---|
196 | BOOST_CHECK(b >= a); |
---|
197 | |
---|
198 | BOOST_CHECK(a == b); |
---|
199 | BOOST_CHECK(!(a != b)); |
---|
200 | |
---|
201 | # ifdef __BORLANDC__ |
---|
202 | ::detail::ignore_unused_variable_warning(a); |
---|
203 | ::detail::ignore_unused_variable_warning(b); |
---|
204 | # endif |
---|
205 | } |
---|
206 | |
---|
207 | int test_main(int, char *[]) { |
---|
208 | test_12_34(); |
---|
209 | test_13_24(); |
---|
210 | test_14_23(); |
---|
211 | test_12_23(); |
---|
212 | test_12_E(); |
---|
213 | test_E_E(); |
---|
214 | test_12_12(); |
---|
215 | test_11_11(); |
---|
216 | |
---|
217 | return 0; |
---|
218 | } |
---|