1 /* Test for the C++ implementation of iseqsig.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
26 /* There is no NaN for _Float128 in std::numeric_limits.
27 Include ieee754_float128.h and use the bitfields in the union
28 ieee854_float128.ieee_nan to build a NaN. */
29 #if __HAVE_DISTINCT_FLOAT128
30 # include <ieee754_float128.h>
33 #include <support/check.h>
36 check (int actual
, int expected
, const char *actual_expr
, int line
)
38 if (actual
!= expected
)
40 support_record_failure ();
41 printf ("%s:%d: error: %s\n", __FILE__
, line
, actual_expr
);
42 printf ("%s:%d: expected: %d\n", __FILE__
, line
, expected
);
43 printf ("%s:%d: actual: %d\n", __FILE__
, line
, actual
);
47 #define CHECK(actual, expected) \
48 check ((actual), (expected), #actual, __LINE__)
50 template <class T1
, class T2
>
56 CHECK (iseqsig (t1
, t2
), 1);
59 CHECK (iseqsig (t1
, t2
), 0);
61 if (std::numeric_limits
<T1
>::has_quiet_NaN
62 && std::numeric_limits
<T2
>::has_quiet_NaN
)
64 CHECK (iseqsig (std::numeric_limits
<T1
>::quiet_NaN (), t2
), 0);
65 CHECK (iseqsig (t1
, std::numeric_limits
<T2
>::quiet_NaN ()), 0);
66 CHECK (iseqsig (std::numeric_limits
<T1
>::quiet_NaN (),
67 std::numeric_limits
<T2
>::quiet_NaN ()), 0);
71 /* Run minimal tests of iseqsig for a pair of types, without relying
72 on C++ library support or knowledge of the representation. */
73 template <class T1
, class T2
>
79 CHECK (iseqsig (t1
, t2
), 1);
82 CHECK (iseqsig (t1
, t2
), 0);
85 #if __HAVE_DISTINCT_FLOAT128
89 ieee854_float128 q1
, q2
, q3_nan
;
93 q3_nan
.ieee_nan
.negative
= 0;
94 q3_nan
.ieee_nan
.exponent
= 0x7FFF;
95 q3_nan
.ieee_nan
.quiet_nan
= 1;
96 q3_nan
.ieee_nan
.mantissa0
= 0x0000;
97 q3_nan
.ieee_nan
.mantissa1
= 0x00000000;
98 q3_nan
.ieee_nan
.mantissa2
= 0x00000000;
99 q3_nan
.ieee_nan
.mantissa3
= 0x00000000;
101 CHECK (iseqsig (q1
.d
, q1
.d
), 1);
102 CHECK (iseqsig (q1
.d
, q2
.d
), 0);
103 CHECK (iseqsig (q1
.d
, q3_nan
.d
), 0);
104 CHECK (iseqsig (q3_nan
.d
, q3_nan
.d
), 0);
111 check_type
<float, float> ();
112 check_type
<float, double> ();
113 check_type
<float, long double> ();
114 check_type
<double, float> ();
115 check_type
<double, double> ();
116 check_type
<double, long double> ();
117 check_type
<long double, float> ();
118 check_type
<long double, double> ();
119 check_type
<long double, long double> ();
120 #if __HAVE_DISTINCT_FLOAT128
125 check_type_minimal
<float, _Float16
> ();
128 check_type_minimal
<float, _Float32
> ();
131 check_type_minimal
<float, _Float64
> ();
134 check_type_minimal
<float, _Float128
> ();
137 check_type_minimal
<float, _Float32x
> ();
140 check_type_minimal
<float, _Float64x
> ();
143 check_type_minimal
<float, _Float128x
> ();
146 check_type_minimal
<double, _Float16
> ();
149 check_type_minimal
<double, _Float32
> ();
152 check_type_minimal
<double, _Float64
> ();
155 check_type_minimal
<double, _Float128
> ();
158 check_type_minimal
<double, _Float32x
> ();
161 check_type_minimal
<double, _Float64x
> ();
164 check_type_minimal
<double, _Float128x
> ();
167 check_type_minimal
<long double, _Float16
> ();
170 check_type_minimal
<long double, _Float32
> ();
173 check_type_minimal
<long double, _Float64
> ();
175 #if __HAVE_FLOAT128 && LDBL_MANT_DIG != 106
176 check_type_minimal
<long double, _Float128
> ();
179 check_type_minimal
<long double, _Float32x
> ();
181 #if __HAVE_FLOAT64X && LDBL_MANT_DIG != 106
182 check_type_minimal
<long double, _Float64x
> ();
184 #if __HAVE_FLOAT128X && LDBL_MANT_DIG != 106
185 check_type_minimal
<long double, _Float128x
> ();
188 check_type_minimal
<_Float16
, float> ();
191 check_type_minimal
<_Float16
, double> ();
194 check_type_minimal
<_Float16
, long double> ();
197 check_type_minimal
<_Float16
, _Float16
> ();
199 #if __HAVE_FLOAT16 && __HAVE_FLOAT32
200 check_type_minimal
<_Float16
, _Float32
> ();
202 #if __HAVE_FLOAT16 && __HAVE_FLOAT64
203 check_type_minimal
<_Float16
, _Float64
> ();
205 #if __HAVE_FLOAT16 && __HAVE_FLOAT128
206 check_type_minimal
<_Float16
, _Float128
> ();
208 #if __HAVE_FLOAT16 && __HAVE_FLOAT32X
209 check_type_minimal
<_Float16
, _Float32x
> ();
211 #if __HAVE_FLOAT16 && __HAVE_FLOAT64X
212 check_type_minimal
<_Float16
, _Float64x
> ();
214 #if __HAVE_FLOAT16 && __HAVE_FLOAT128X
215 check_type_minimal
<_Float16
, _Float128x
> ();
218 check_type_minimal
<_Float32
, float> ();
221 check_type_minimal
<_Float32
, double> ();
224 check_type_minimal
<_Float32
, long double> ();
226 #if __HAVE_FLOAT32 && __HAVE_FLOAT16
227 check_type_minimal
<_Float32
, _Float16
> ();
230 check_type_minimal
<_Float32
, _Float32
> ();
232 #if __HAVE_FLOAT32 && __HAVE_FLOAT64
233 check_type_minimal
<_Float32
, _Float64
> ();
235 #if __HAVE_FLOAT32 && __HAVE_FLOAT128
236 check_type_minimal
<_Float32
, _Float128
> ();
238 #if __HAVE_FLOAT32 && __HAVE_FLOAT32X
239 check_type_minimal
<_Float32
, _Float32x
> ();
241 #if __HAVE_FLOAT32 && __HAVE_FLOAT64X
242 check_type_minimal
<_Float32
, _Float64x
> ();
244 #if __HAVE_FLOAT32 && __HAVE_FLOAT128X
245 check_type_minimal
<_Float32
, _Float128x
> ();
248 check_type_minimal
<_Float64
, float> ();
251 check_type_minimal
<_Float64
, double> ();
254 check_type_minimal
<_Float64
, long double> ();
256 #if __HAVE_FLOAT64 && __HAVE_FLOAT16
257 check_type_minimal
<_Float64
, _Float16
> ();
259 #if __HAVE_FLOAT64 && __HAVE_FLOAT32
260 check_type_minimal
<_Float64
, _Float32
> ();
263 check_type_minimal
<_Float64
, _Float64
> ();
265 #if __HAVE_FLOAT64 && __HAVE_FLOAT128
266 check_type_minimal
<_Float64
, _Float128
> ();
268 #if __HAVE_FLOAT64 && __HAVE_FLOAT32X
269 check_type_minimal
<_Float64
, _Float32x
> ();
271 #if __HAVE_FLOAT64 && __HAVE_FLOAT64X
272 check_type_minimal
<_Float64
, _Float64x
> ();
274 #if __HAVE_FLOAT64 && __HAVE_FLOAT128X
275 check_type_minimal
<_Float64
, _Float128x
> ();
278 check_type_minimal
<_Float128
, float> ();
281 check_type_minimal
<_Float128
, double> ();
283 #if __HAVE_FLOAT128 && LDBL_MANT_DIG != 106
284 check_type_minimal
<_Float128
, long double> ();
286 #if __HAVE_FLOAT128 && __HAVE_FLOAT16
287 check_type_minimal
<_Float128
, _Float16
> ();
289 #if __HAVE_FLOAT128 && __HAVE_FLOAT32
290 check_type_minimal
<_Float128
, _Float32
> ();
292 #if __HAVE_FLOAT128 && __HAVE_FLOAT64
293 check_type_minimal
<_Float128
, _Float64
> ();
296 check_type_minimal
<_Float128
, _Float128
> ();
298 #if __HAVE_FLOAT128 && __HAVE_FLOAT32X
299 check_type_minimal
<_Float128
, _Float32x
> ();
301 #if __HAVE_FLOAT128 && __HAVE_FLOAT64X
302 check_type_minimal
<_Float128
, _Float64x
> ();
304 #if __HAVE_FLOAT128 && __HAVE_FLOAT128X
305 check_type_minimal
<_Float128
, _Float128x
> ();
308 check_type_minimal
<_Float32x
, float> ();
311 check_type_minimal
<_Float32x
, double> ();
314 check_type_minimal
<_Float32x
, long double> ();
316 #if __HAVE_FLOAT32X && __HAVE_FLOAT16
317 check_type_minimal
<_Float32x
, _Float16
> ();
319 #if __HAVE_FLOAT32X && __HAVE_FLOAT32
320 check_type_minimal
<_Float32x
, _Float32
> ();
322 #if __HAVE_FLOAT32X && __HAVE_FLOAT64
323 check_type_minimal
<_Float32x
, _Float64
> ();
325 #if __HAVE_FLOAT32X && __HAVE_FLOAT128
326 check_type_minimal
<_Float32x
, _Float128
> ();
329 check_type_minimal
<_Float32x
, _Float32x
> ();
331 #if __HAVE_FLOAT32X && __HAVE_FLOAT64X
332 check_type_minimal
<_Float32x
, _Float64x
> ();
334 #if __HAVE_FLOAT32X && __HAVE_FLOAT128X
335 check_type_minimal
<_Float32x
, _Float128x
> ();
338 check_type_minimal
<_Float64x
, float> ();
341 check_type_minimal
<_Float64x
, double> ();
343 #if __HAVE_FLOAT64X && LDBL_MANT_DIG != 106
344 check_type_minimal
<_Float64x
, long double> ();
346 #if __HAVE_FLOAT64X && __HAVE_FLOAT16
347 check_type_minimal
<_Float64x
, _Float16
> ();
349 #if __HAVE_FLOAT64X && __HAVE_FLOAT32
350 check_type_minimal
<_Float64x
, _Float32
> ();
352 #if __HAVE_FLOAT64X && __HAVE_FLOAT64
353 check_type_minimal
<_Float64x
, _Float64
> ();
355 #if __HAVE_FLOAT64X && __HAVE_FLOAT128
356 check_type_minimal
<_Float64x
, _Float128
> ();
358 #if __HAVE_FLOAT64X && __HAVE_FLOAT32X
359 check_type_minimal
<_Float64x
, _Float32x
> ();
362 check_type_minimal
<_Float64x
, _Float64x
> ();
364 #if __HAVE_FLOAT64X && __HAVE_FLOAT128X
365 check_type_minimal
<_Float64x
, _Float128x
> ();
368 check_type_minimal
<_Float128x
, float> ();
371 check_type_minimal
<_Float128x
, double> ();
373 #if __HAVE_FLOAT128X && LDBL_MANT_DIG != 106
374 check_type_minimal
<_Float128x
, long double> ();
376 #if __HAVE_FLOAT128X && __HAVE_FLOAT16
377 check_type_minimal
<_Float128x
, _Float16
> ();
379 #if __HAVE_FLOAT128X && __HAVE_FLOAT32
380 check_type_minimal
<_Float128x
, _Float32
> ();
382 #if __HAVE_FLOAT128X && __HAVE_FLOAT64
383 check_type_minimal
<_Float128x
, _Float64
> ();
385 #if __HAVE_FLOAT128X && __HAVE_FLOAT128
386 check_type_minimal
<_Float128x
, _Float128
> ();
388 #if __HAVE_FLOAT128X && __HAVE_FLOAT32X
389 check_type_minimal
<_Float128x
, _Float32x
> ();
391 #if __HAVE_FLOAT128X && __HAVE_FLOAT64X
392 check_type_minimal
<_Float128x
, _Float64x
> ();
395 check_type_minimal
<_Float128x
, _Float128x
> ();
401 #include <support/test-driver.c>