Remove unused variable from stdlib/setenv.c
[platform/upstream/glibc.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 test (const char str[])
8 {
9   char *endp;
10   int result = 0;
11
12   puts (str);
13
14   double d = strtod (str, &endp);
15   if (!isnan (d))
16     {
17       puts ("strtod did not return NAN");
18       result = 1;
19     }
20   if (issignaling (d))
21     {
22       puts ("strtod returned a sNAN");
23       result = 1;
24     }
25   if (strcmp (endp, "something") != 0)
26     {
27       puts  ("strtod set incorrect end pointer");
28       result = 1;
29     }
30
31   float f = strtof (str, &endp);
32   if (!isnanf (f))
33     {
34       puts ("strtof did not return NAN");
35       result = 1;
36     }
37   if (issignaling (f))
38     {
39       puts ("strtof returned a sNAN");
40       result = 1;
41     }
42   if (strcmp (endp, "something") != 0)
43     {
44       puts  ("strtof set incorrect end pointer");
45       result = 1;
46     }
47
48   long double ld = strtold (str, &endp);
49   if (!isnan (ld))
50     {
51       puts ("strtold did not return NAN");
52       result = 1;
53     }
54   if (issignaling (ld))
55     {
56       puts ("strtold returned a sNAN");
57       result = 1;
58     }
59   if (strcmp (endp, "something") != 0)
60     {
61       puts  ("strtold set incorrect end pointer");
62       result = 1;
63     }
64
65   return result;
66 }
67
68 static int
69 do_test (void)
70 {
71   int result = 0;
72
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");
83
84   return result;
85 }
86
87 #define TEST_FUNCTION do_test ()
88 #include "../test-skeleton.c"