powerpc: Fix Copyright dates and CL entry
[glibc.git] / stdlib / tst-strtod6.c
blob15e79fddfbc0d837ad2123ea1de835908487a22c
1 #include <math.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
6 static int
7 test (const char str[])
9 char *endp;
10 int result = 0;
12 puts (str);
14 double d = strtod (str, &endp);
15 if (!isnan (d))
17 puts ("strtod did not return NAN");
18 result = 1;
20 if (issignaling (d))
22 puts ("strtod returned a sNAN");
23 result = 1;
25 if (strcmp (endp, "something") != 0)
27 puts ("strtod set incorrect end pointer");
28 result = 1;
31 float f = strtof (str, &endp);
32 if (!isnanf (f))
34 puts ("strtof did not return NAN");
35 result = 1;
37 if (issignaling (f))
39 puts ("strtof returned a sNAN");
40 result = 1;
42 if (strcmp (endp, "something") != 0)
44 puts ("strtof set incorrect end pointer");
45 result = 1;
48 long double ld = strtold (str, &endp);
49 if (!isnan (ld))
51 puts ("strtold did not return NAN");
52 result = 1;
54 if (issignaling (ld))
56 puts ("strtold returned a sNAN");
57 result = 1;
59 if (strcmp (endp, "something") != 0)
61 puts ("strtold set incorrect end pointer");
62 result = 1;
65 return result;
68 static int
69 do_test (void)
71 int result = 0;
73 result |= test ("NaN(blabla)something");
74 result |= test ("NaN(1234)something");
75 /* UINT32_MAX. */
76 result |= test ("NaN(4294967295)something");
77 /* UINT64_MAX. */
78 result |= test ("NaN(18446744073709551615)something");
79 /* The case of zero is special in that "something" has to be done to make the
80 mantissa different from zero, which would mean infinity instead of
81 NaN. */
82 result |= test ("NaN(0)something");
84 return result;
87 #define TEST_FUNCTION do_test ()
88 #include "../test-skeleton.c"