]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/ieee754/ldbl-128ibm/tst-strtold-ldbl-128ibm.c
1 /* Test for ldbl-128ibm strtold overflow to infinity (bug 14551).
2 Copyright (C) 2015-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 test_strtold_value (const char *s
, double exp_hi
, double exp_lo
, int exp_exc
,
30 union { long double ld
; double d
[2]; } x
;
31 feclearexcept (FE_ALL_EXCEPT
);
33 x
.ld
= strtold (s
, NULL
);
34 int exc
= fetestexcept (FE_ALL_EXCEPT
);
35 int new_errno
= errno
;
36 printf ("strtold (\"%s\") returned (%a, %a), exceptions 0x%x, errno %d\n",
37 s
, x
.d
[0], x
.d
[1], exc
, new_errno
);
39 printf ("PASS: strtold (\"%s\") high == %a\n", s
, exp_hi
);
42 printf ("FAIL: strtold (\"%s\") high == %a\n", s
, exp_hi
);
46 printf ("PASS: strtold (\"%s\") low == %a\n", s
, exp_lo
);
49 printf ("FAIL: strtold (\"%s\") low == %a\n", s
, exp_lo
);
53 printf ("PASS: strtold (\"%s\") exceptions 0x%x\n", s
, exp_exc
);
56 printf ("FAIL: strtold (\"%s\") exceptions 0x%x\n", s
, exp_exc
);
59 if (new_errno
== exp_errno
)
60 printf ("PASS: strtold (\"%s\") errno %d\n", s
, exp_errno
);
63 printf ("FAIL: strtold (\"%s\") errno %d\n", s
, exp_errno
);
73 result
|= test_strtold_value ("0x1.fffffffffffff8p+1023", INFINITY
, 0,
74 FE_OVERFLOW
| FE_INEXACT
, ERANGE
);
75 result
|= test_strtold_value ("-0x1.fffffffffffff8p+1023", -INFINITY
, 0,
76 FE_OVERFLOW
| FE_INEXACT
, ERANGE
);
77 result
|= test_strtold_value ("0x1.ffffffffffffffp+1023", INFINITY
, 0,
78 FE_OVERFLOW
| FE_INEXACT
, ERANGE
);
79 result
|= test_strtold_value ("-0x1.ffffffffffffffp+1023", -INFINITY
, 0,
80 FE_OVERFLOW
| FE_INEXACT
, ERANGE
);
84 #define TEST_FUNCTION do_test ()
85 #include "../../../test-skeleton.c"