comparison tests/test-strtold.c @ 40171:fbfa1d6417d9

strtod, strtold tests: Simplify tests. * tests/test-strtod.c (main): Assume no rounding errors for 0.5. * tests/test-strtold.c (main): Likewise.
author Bruno Haible <bruno@clisp.org>
date Fri, 01 Feb 2019 02:51:20 +0100
parents c1aa6d1185ea
children
comparison
equal deleted inserted replaced
40170:201ca4418b4b 40171:fbfa1d6417d9
153 const char input[] = ".5"; 153 const char input[] = ".5";
154 char *ptr; 154 char *ptr;
155 long double result; 155 long double result;
156 errno = 0; 156 errno = 0;
157 result = strtold (input, &ptr); 157 result = strtold (input, &ptr);
158 /* FIXME - gnulib's version is rather inaccurate. It would be 158 ASSERT (result == 0.5L);
159 nice to guarantee an exact result, but for now, we settle for a
160 1-ulp error. */
161 ASSERT (FABSL (result - 0.5L) < LDBL_EPSILON);
162 ASSERT (ptr == input + 2); 159 ASSERT (ptr == input + 2);
163 ASSERT (errno == 0); 160 ASSERT (errno == 0);
164 } 161 }
165 { 162 {
166 const char input[] = " 1"; 163 const char input[] = " 1";
236 const char input[] = "5e-1"; 233 const char input[] = "5e-1";
237 char *ptr; 234 char *ptr;
238 long double result; 235 long double result;
239 errno = 0; 236 errno = 0;
240 result = strtold (input, &ptr); 237 result = strtold (input, &ptr);
241 /* FIXME - gnulib's version is rather inaccurate. It would be 238 ASSERT (result == 0.5L);
242 nice to guarantee an exact result, but for now, we settle for a
243 1-ulp error. */
244 ASSERT (FABSL (result - 0.5L) < LDBL_EPSILON);
245 ASSERT (ptr == input + 4); 239 ASSERT (ptr == input + 4);
246 ASSERT (errno == 0); 240 ASSERT (errno == 0);
247 } 241 }
248 242
249 /* Zero. */ 243 /* Zero. */