chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / stdlib / tst-strtod6.c
1 #include <math.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5
6 static int
7 do_test (void)
8 {
9   static const char str[] = "NaN(blabla)something";
10   char *endp;
11   int result = 0;
12
13   double d = strtod (str, &endp);
14   if (!isnan (d))
15     {
16       puts ("strtod did not return NAN");
17       result = 1;
18     }
19   if (strcmp (endp, "something") != 0)
20     {
21       puts  ("strtod set incorrect end pointer");
22       result = 1;
23     }
24
25   float f = strtof (str, &endp);
26   if (!isnanf (f))
27     {
28       puts ("strtof did not return NAN");
29       result = 1;
30     }
31   if (strcmp (endp, "something") != 0)
32     {
33       puts  ("strtof set incorrect end pointer");
34       result = 1;
35     }
36
37   long double ld = strtold (str, &endp);
38   if (!isnan (ld))
39     {
40       puts ("strtold did not return NAN");
41       result = 1;
42     }
43   if (strcmp (endp, "something") != 0)
44     {
45       puts  ("strtold set incorrect end pointer");
46       result = 1;
47     }
48
49   return result;
50 }
51
52 #define TEST_FUNCTION do_test ()
53 #include "../test-skeleton.c"