1 /* Test a totalordermag-like function.
2 Copyright 2023-2025 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program 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
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
23 /* The IBM XL C compiler cannot compile the initializer of x[] below. */
30 fputs ("Skipping test: broken C compiler\n", stderr
);
36 # include "infinity.h"
38 # include "minus-zero.h"
39 # include "signed-nan.h"
40 # include "signed-snan.h"
42 static TOTALORDER_TYPE
43 positive_NaN_with_payload (int payload
)
46 ASSERT (TOTALORDER_SETPAYLOAD (&x
.value
, payload
) == 0);
50 static TOTALORDER_TYPE
51 negative_NaN_with_payload (int payload
)
54 ASSERT (TOTALORDER_SETPAYLOAD (&x
.value
, payload
) == 0);
55 x
.value
= TOTALORDER_MINUS (x
.value
);
64 negative_NaN_with_payload (1729),
65 negative_NaN_with_payload (641),
66 # if TOTALORDER_HAVE_SNAN
67 TOTALORDER_NEGATIVE_SNAN (),
69 { -TOTALORDER_INF () },
73 { TOTALORDER_MINUS_ZERO
},
78 { TOTALORDER_INF () },
79 # if TOTALORDER_HAVE_SNAN
80 TOTALORDER_POSITIVE_SNAN (),
82 positive_NaN_with_payload (641),
83 positive_NaN_with_payload (1729)
87 for (int i
= 0; i
< n
; i
++)
88 for (int j
= 0; j
< n
; j
++)
89 if (!(!!TOTALORDER (&x
[i
].value
, &x
[j
].value
)
90 == ((i
< n
/ 2 ? n
- 1 - i
: i
) <= (j
< n
/2 ? n
- 1 - j
: j
))))
92 fprintf (stderr
, "Failed: i=%d j=%d\n", i
, j
);
93 test_exit_status
= EXIT_FAILURE
;
96 return test_exit_status
;