Back to index

glibc  2.9
tst-strtod6.c
Go to the documentation of this file.
00001 #include <math.h>
00002 #include <stdio.h>
00003 #include <stdlib.h>
00004 #include <string.h>
00005 
00006 static int
00007 do_test (void)
00008 {
00009   static const char str[] = "NaN(blabla)something";
00010   char *endp;
00011   int result = 0;
00012 
00013   double d = strtod (str, &endp);
00014   if (!isnan (d))
00015     {
00016       puts ("strtod did not return NAN");
00017       result = 1;
00018     }
00019   if (strcmp (endp, "something") != 0)
00020     {
00021       puts  ("strtod set incorrect end pointer");
00022       result = 1;
00023     }
00024 
00025   float f = strtof (str, &endp);
00026   if (!isnanf (f))
00027     {
00028       puts ("strtof did not return NAN");
00029       result = 1;
00030     }
00031   if (strcmp (endp, "something") != 0)
00032     {
00033       puts  ("strtof set incorrect end pointer");
00034       result = 1;
00035     }
00036 
00037   long double ld = strtold (str, &endp);
00038   if (!isnan (ld))
00039     {
00040       puts ("strtold did not return NAN");
00041       result = 1;
00042     }
00043   if (strcmp (endp, "something") != 0)
00044     {
00045       puts  ("strtold set incorrect end pointer");
00046       result = 1;
00047     }
00048 
00049   return result;
00050 }
00051 
00052 #define TEST_FUNCTION do_test ()
00053 #include "../test-skeleton.c"