1 // Copyright (C) 2009-2018 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-require-effective-target dfp }
20 // ISO/IEC TR 24733 3.2.9 Comparison operators.
22 #include <decimal/decimal>
23 #include <testsuite_hooks.h>
25 using namespace std::decimal
;
33 unsigned long ul
= 20;
35 unsigned long long ull
= 50;
42 a
= si
; VERIFY (a
== si
); VERIFY (si
== a
);
43 a
= ui
; VERIFY (a
== ui
); VERIFY (ui
== a
);
44 a
= sl
; VERIFY (a
== sl
); VERIFY (sl
== a
);
45 a
= ul
; VERIFY (a
== ul
); VERIFY (ul
== a
);
46 a
= sll
; VERIFY (a
== sll
); VERIFY (sll
== a
);
47 a
= ull
; VERIFY (a
== ull
); VERIFY (ull
== a
);
48 a
= d32
; VERIFY (a
== d32
); VERIFY (d32
== a
);
49 a
= (decimal32
)d64
; VERIFY (a
== d64
); VERIFY (d64
== a
);
50 a
= (decimal32
)d128
; VERIFY (a
== d128
); VERIFY (d128
== a
);
58 VERIFY (a
!= si
); VERIFY (si
!= a
);
59 VERIFY (a
!= ui
); VERIFY (ui
!= a
);
60 VERIFY (a
!= sl
); VERIFY (sl
!= a
);
61 VERIFY (a
!= ul
); VERIFY (ul
!= a
);
62 VERIFY (a
!= sll
); VERIFY (sll
!= a
);
63 VERIFY (a
!= ull
); VERIFY (ull
!= a
);
64 VERIFY (a
!= d32
); VERIFY (d32
!= a
);
65 VERIFY (a
!= d64
); VERIFY (d64
!= a
);
66 VERIFY (a
!= d128
); VERIFY (d128
!= a
);
101 a
= si
; VERIFY (a
<= si
); VERIFY (si
<= a
);
102 a
= ui
; VERIFY (a
<= ui
); VERIFY (ui
<= a
);
103 a
= sl
; VERIFY (a
<= sl
); VERIFY (sl
<= a
);
104 a
= ul
; VERIFY (a
<= ul
); VERIFY (ul
<= a
);
105 a
= sll
; VERIFY (a
<= sll
); VERIFY (sll
<= a
);
106 a
= ull
; VERIFY (a
<= ull
); VERIFY (ull
<= a
);
107 a
= d32
; VERIFY (a
<= d32
); VERIFY (d32
<= a
);
108 a
= (decimal32
)d64
; VERIFY (a
<= d64
); VERIFY (d64
<= a
);
109 a
= (decimal32
)d128
; VERIFY (a
<= d128
); VERIFY (d128
<= a
);
166 a
= si
; VERIFY (a
>= si
); VERIFY (si
<= a
);
167 a
= ui
; VERIFY (a
>= ui
); VERIFY (ui
<= a
);
168 a
= sl
; VERIFY (a
>= sl
); VERIFY (sl
<= a
);
169 a
= ul
; VERIFY (a
>= ul
); VERIFY (ul
<= a
);
170 a
= sll
; VERIFY (a
>= sll
); VERIFY (sll
<= a
);
171 a
= ull
; VERIFY (a
>= ull
); VERIFY (ull
<= a
);
172 a
= d32
; VERIFY (a
>= d32
); VERIFY (d32
<= a
);
173 a
= (decimal32
)d64
; VERIFY (a
>= d64
); VERIFY (d64
<= a
);
174 a
= (decimal32
)d128
; VERIFY (a
>= d128
); VERIFY (d128
<= a
);
204 a
= si
; VERIFY (a
== si
); VERIFY (si
== a
);
205 a
= ui
; VERIFY (a
== ui
); VERIFY (ui
== a
);
206 a
= sl
; VERIFY (a
== sl
); VERIFY (sl
== a
);
207 a
= ul
; VERIFY (a
== ul
); VERIFY (ul
== a
);
208 a
= sll
; VERIFY (a
== sll
); VERIFY (sll
== a
);
209 a
= ull
; VERIFY (a
== ull
); VERIFY (ull
== a
);
210 a
= d32
; VERIFY (a
== d32
); VERIFY (d32
== a
);
211 a
= d64
; VERIFY (a
== d64
); VERIFY (d64
== a
);
212 a
= (decimal64
)d128
; VERIFY (a
== d128
); VERIFY (d128
== a
);
220 VERIFY (a
!= si
); VERIFY (si
!= a
);
221 VERIFY (a
!= ui
); VERIFY (ui
!= a
);
222 VERIFY (a
!= sl
); VERIFY (sl
!= a
);
223 VERIFY (a
!= ul
); VERIFY (ul
!= a
);
224 VERIFY (a
!= sll
); VERIFY (sll
!= a
);
225 VERIFY (a
!= ull
); VERIFY (ull
!= a
);
226 VERIFY (a
!= d32
); VERIFY (d32
!= a
);
227 VERIFY (a
!= d64
); VERIFY (d64
!= a
);
228 VERIFY (a
!= d128
); VERIFY (d128
!= a
);
263 a
= si
; VERIFY (a
<= si
); VERIFY (si
<= a
);
264 a
= ui
; VERIFY (a
<= ui
); VERIFY (ui
<= a
);
265 a
= sl
; VERIFY (a
<= sl
); VERIFY (sl
<= a
);
266 a
= ul
; VERIFY (a
<= ul
); VERIFY (ul
<= a
);
267 a
= sll
; VERIFY (a
<= sll
); VERIFY (sll
<= a
);
268 a
= ull
; VERIFY (a
<= ull
); VERIFY (ull
<= a
);
269 a
= d32
; VERIFY (a
<= d32
); VERIFY (d32
<= a
);
270 a
= (decimal32
)d64
; VERIFY (a
<= d64
); VERIFY (d64
<= a
);
271 a
= (decimal32
)d128
; VERIFY (a
<= d128
); VERIFY (d128
<= a
);
328 a
= si
; VERIFY (a
>= si
); VERIFY (si
<= a
);
329 a
= ui
; VERIFY (a
>= ui
); VERIFY (ui
<= a
);
330 a
= sl
; VERIFY (a
>= sl
); VERIFY (sl
<= a
);
331 a
= ul
; VERIFY (a
>= ul
); VERIFY (ul
<= a
);
332 a
= sll
; VERIFY (a
>= sll
); VERIFY (sll
<= a
);
333 a
= ull
; VERIFY (a
>= ull
); VERIFY (ull
<= a
);
334 a
= d32
; VERIFY (a
>= d32
); VERIFY (d32
<= a
);
335 a
= (decimal32
)d64
; VERIFY (a
>= d64
); VERIFY (d64
<= a
);
336 a
= (decimal32
)d128
; VERIFY (a
>= d128
); VERIFY (d128
<= a
);
362 compare_eq_128 (void)
366 a
= si
; VERIFY (a
== si
); VERIFY (si
== a
);
367 a
= ui
; VERIFY (a
== ui
); VERIFY (ui
== a
);
368 a
= sl
; VERIFY (a
== sl
); VERIFY (sl
== a
);
369 a
= ul
; VERIFY (a
== ul
); VERIFY (ul
== a
);
370 a
= sll
; VERIFY (a
== sll
); VERIFY (sll
== a
);
371 a
= ull
; VERIFY (a
== ull
); VERIFY (ull
== a
);
372 a
= d32
; VERIFY (a
== d32
); VERIFY (d32
== a
);
373 a
= d64
; VERIFY (a
== d64
); VERIFY (d64
== a
);
374 a
= d128
; VERIFY (a
== d128
); VERIFY (d128
== a
);
378 compare_ne_128 (void)
382 VERIFY (a
!= si
); VERIFY (si
!= a
);
383 VERIFY (a
!= ui
); VERIFY (ui
!= a
);
384 VERIFY (a
!= sl
); VERIFY (sl
!= a
);
385 VERIFY (a
!= ul
); VERIFY (ul
!= a
);
386 VERIFY (a
!= sll
); VERIFY (sll
!= a
);
387 VERIFY (a
!= ull
); VERIFY (ull
!= a
);
388 VERIFY (a
!= d32
); VERIFY (d32
!= a
);
389 VERIFY (a
!= d64
); VERIFY (d64
!= a
);
390 VERIFY (a
!= d128
); VERIFY (d128
!= a
);
394 compare_lt_128 (void)
421 compare_le_128 (void)
425 a
= si
; VERIFY (a
<= si
); VERIFY (si
<= a
);
426 a
= ui
; VERIFY (a
<= ui
); VERIFY (ui
<= a
);
427 a
= sl
; VERIFY (a
<= sl
); VERIFY (sl
<= a
);
428 a
= ul
; VERIFY (a
<= ul
); VERIFY (ul
<= a
);
429 a
= sll
; VERIFY (a
<= sll
); VERIFY (sll
<= a
);
430 a
= ull
; VERIFY (a
<= ull
); VERIFY (ull
<= a
);
431 a
= d32
; VERIFY (a
<= d32
); VERIFY (d32
<= a
);
432 a
= (decimal32
)d64
; VERIFY (a
<= d64
); VERIFY (d64
<= a
);
433 a
= (decimal32
)d128
; VERIFY (a
<= d128
); VERIFY (d128
<= a
);
459 compare_gt_128 (void)
486 compare_ge_128 (void)
490 a
= si
; VERIFY (a
>= si
); VERIFY (si
<= a
);
491 a
= ui
; VERIFY (a
>= ui
); VERIFY (ui
<= a
);
492 a
= sl
; VERIFY (a
>= sl
); VERIFY (sl
<= a
);
493 a
= ul
; VERIFY (a
>= ul
); VERIFY (ul
<= a
);
494 a
= sll
; VERIFY (a
>= sll
); VERIFY (sll
<= a
);
495 a
= ull
; VERIFY (a
>= ull
); VERIFY (ull
<= a
);
496 a
= d32
; VERIFY (a
>= d32
); VERIFY (d32
<= a
);
497 a
= (decimal32
)d64
; VERIFY (a
>= d64
); VERIFY (d64
<= a
);
498 a
= (decimal32
)d128
; VERIFY (a
>= d128
); VERIFY (d128
<= a
);