]>
Commit | Line | Data |
---|---|---|
b3278554 UD |
1 | #include <math.h> |
2 | #include <stdio.h> | |
3 | #include <stdlib.h> | |
4 | #include <string.h> | |
5 | ||
db1fa6b8 PM |
6 | #include "tst-strtod.h" |
7 | ||
bf5eea32 | 8 | #define TEST_STRTOD(FSUF, FTYPE, FTOSTR, LSUF, CSUF) \ |
db1fa6b8 PM |
9 | static int \ |
10 | test_strto ## FSUF (const char str[]) \ | |
11 | { \ | |
12 | char *endp; \ | |
13 | int result = 0; \ | |
14 | puts (str); \ | |
15 | FTYPE d = strto ## FSUF (str, &endp); \ | |
16 | if (!isnan (d)) \ | |
17 | { \ | |
18 | puts ("strto" #FSUF " did not return NAN"); \ | |
19 | result = 1; \ | |
20 | } \ | |
21 | if (issignaling (d)) \ | |
22 | { \ | |
23 | puts ("strto" #FSUF " returned a sNAN"); \ | |
24 | result = 1; \ | |
25 | } \ | |
26 | if (strcmp (endp, "something") != 0) \ | |
27 | { \ | |
28 | puts ("strto" #FSUF " set incorrect end pointer"); \ | |
29 | result = 1; \ | |
30 | } \ | |
31 | return result; \ | |
b3278554 UD |
32 | } |
33 | ||
db1fa6b8 PM |
34 | GEN_TEST_STRTOD_FOREACH (TEST_STRTOD); |
35 | ||
0007fc9b TS |
36 | static int |
37 | do_test (void) | |
38 | { | |
39 | int result = 0; | |
40 | ||
db1fa6b8 PM |
41 | result |= STRTOD_TEST_FOREACH (test_strto, "NaN(blabla)something"); |
42 | result |= STRTOD_TEST_FOREACH (test_strto, "NaN(1234)something"); | |
0007fc9b | 43 | /* UINT32_MAX. */ |
db1fa6b8 | 44 | result |= STRTOD_TEST_FOREACH (test_strto, "NaN(4294967295)something"); |
0007fc9b | 45 | /* UINT64_MAX. */ |
db1fa6b8 PM |
46 | result |= STRTOD_TEST_FOREACH (test_strto, |
47 | "NaN(18446744073709551615)something"); | |
0007fc9b TS |
48 | /* The case of zero is special in that "something" has to be done to make the |
49 | mantissa different from zero, which would mean infinity instead of | |
50 | NaN. */ | |
db1fa6b8 | 51 | result |= STRTOD_TEST_FOREACH (test_strto, "NaN(0)something"); |
0007fc9b TS |
52 | |
53 | return result; | |
54 | } | |
55 | ||
b3278554 UD |
56 | #define TEST_FUNCTION do_test () |
57 | #include "../test-skeleton.c" |