1 /* Test for the C++ implementation of iseqsig.
2 Copyright (C) 2017-2019 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 <http://www.gnu.org/licenses/>. */
25 /* There is no NaN for _Float128 in std::numeric_limits.
26 Include ieee754_float128.h and use the bitfields in the union
27 ieee854_float128.ieee_nan to build a NaN. */
28 #if __HAVE_DISTINCT_FLOAT128
29 # include <ieee754_float128.h>
32 #include <support/check.h>
35 check (int actual
, int expected
, const char *actual_expr
, int line
)
37 if (actual
!= expected
)
39 support_record_failure ();
40 printf ("%s:%d: error: %s\n", __FILE__
, line
, actual_expr
);
41 printf ("%s:%d: expected: %d\n", __FILE__
, line
, expected
);
42 printf ("%s:%d: actual: %d\n", __FILE__
, line
, actual
);
46 #define CHECK(actual, expected) \
47 check ((actual), (expected), #actual, __LINE__)
49 template <class T1
, class T2
>
55 CHECK (iseqsig (t1
, t2
), 1);
58 CHECK (iseqsig (t1
, t2
), 0);
60 if (std::numeric_limits
<T1
>::has_quiet_NaN
61 && std::numeric_limits
<T2
>::has_quiet_NaN
)
63 CHECK (iseqsig (std::numeric_limits
<T1
>::quiet_NaN (), t2
), 0);
64 CHECK (iseqsig (t1
, std::numeric_limits
<T2
>::quiet_NaN ()), 0);
65 CHECK (iseqsig (std::numeric_limits
<T1
>::quiet_NaN (),
66 std::numeric_limits
<T2
>::quiet_NaN ()), 0);
70 #if __HAVE_DISTINCT_FLOAT128
74 ieee854_float128 q1
, q2
, q3_nan
;
78 q3_nan
.ieee_nan
.negative
= 0;
79 q3_nan
.ieee_nan
.exponent
= 0x7FFF;
80 q3_nan
.ieee_nan
.quiet_nan
= 1;
81 q3_nan
.ieee_nan
.mantissa0
= 0x0000;
82 q3_nan
.ieee_nan
.mantissa1
= 0x00000000;
83 q3_nan
.ieee_nan
.mantissa2
= 0x00000000;
84 q3_nan
.ieee_nan
.mantissa3
= 0x00000000;
86 CHECK (iseqsig (q1
.d
, q1
.d
), 1);
87 CHECK (iseqsig (q1
.d
, q2
.d
), 0);
88 CHECK (iseqsig (q1
.d
, q3_nan
.d
), 0);
89 CHECK (iseqsig (q3_nan
.d
, q3_nan
.d
), 0);
96 check_type
<float, float> ();
97 check_type
<float, double> ();
98 check_type
<float, long double> ();
99 check_type
<double, float> ();
100 check_type
<double, double> ();
101 check_type
<double, long double> ();
102 check_type
<long double, float> ();
103 check_type
<long double, double> ();
104 check_type
<long double, long double> ();
105 #if __HAVE_DISTINCT_FLOAT128
111 #include <support/test-driver.c>