]>
Commit | Line | Data |
---|---|---|
b12c1e79 JM |
1 | /* Test strtod functions handle signs of NaNs (bug 23007). |
2 | Copyright (C) 2018 Free Software Foundation, Inc. | |
3 | This file is part of the GNU C Library. | |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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/>. */ | |
18 | ||
19 | #include <math.h> | |
20 | #include <stdlib.h> | |
21 | #include <wchar.h> | |
22 | ||
23 | #include <stdlib/tst-strtod.h> | |
24 | #include <support/check.h> | |
25 | ||
26 | #define CONCAT_(X, Y) X ## Y | |
27 | #define CONCAT(X, Y) CONCAT_ (X, Y) | |
28 | #define FNX(FN) CONCAT (FNPFX, FN) | |
29 | ||
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; \ | |
41 | } | |
42 | GEN_TEST_STRTOD_FOREACH (TEST_STRTOD) | |
43 | ||
44 | static int | |
45 | do_test (void) | |
46 | { | |
47 | return STRTOD_TEST_FOREACH (test_strto); | |
48 | } | |
49 | ||
50 | #include <support/test-driver.c> |