gshadow: Matching sgetsgent, sgetsgent_r ERANGE handling (bug 30151)
[glibc.git] / stdlib / tst-strtod-nan-sign-main.c
blob2c660ac0339eca9d855f9f16e3d8970c5259c26b
1 /* Test strtod functions handle signs of NaNs (bug 23007).
2 Copyright (C) 2018-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/>. */
19 #include <math.h>
20 #include <stdlib.h>
21 #include <wchar.h>
23 #include <stdlib/tst-strtod.h>
24 #include <support/check.h>
26 #define CONCAT_(X, Y) X ## Y
27 #define CONCAT(X, Y) CONCAT_ (X, Y)
28 #define FNX(FN) CONCAT (FNPFX, FN)
30 #define TEST_STRTOD(FSUF, FTYPE, FTOSTR, LSUF, CSUF) \
31 static int \
32 test_strto ## FSUF (void) \
33 { \
34 FTYPE val_pos = FNX (FSUF) (L_("nan"), NULL); \
35 FTYPE copy_pos = copysign ## CSUF (1, val_pos); \
36 TEST_VERIFY (isnan (val_pos) && copy_pos == 1); \
37 FTYPE val_neg = FNX (FSUF) (L_("-nan"), NULL); \
38 FTYPE copy_neg = copysign ## CSUF (1, val_neg); \
39 TEST_VERIFY (isnan (val_neg) && copy_neg == -1); \
40 return 0; \
42 GEN_TEST_STRTOD_FOREACH (TEST_STRTOD)
44 static int
45 do_test (void)
47 return STRTOD_TEST_FOREACH (test_strto);
50 #include <support/test-driver.c>