Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* stdlib/strtod_l.c (____STRTOF_INTERNAL): Properly handle -0.
* stdlib/Makefile (tests): Add tst-strtod5. (tst-strtod5-ENV): New. * stdlib/tst-strtod5.c: New file.
- Loading branch information
Ulrich Drepper
committed
Aug 3, 2007
1 parent
ce31a3b
commit 64f6281
Showing
5 changed files
with
217 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#include <locale.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <math.h> | ||
|
||
#define NBSP "\xc2\xa0" | ||
|
||
static const struct | ||
{ | ||
const char *in; | ||
int group; | ||
double expected; | ||
} tests[] = | ||
{ | ||
{ "0", 0, 0.0 }, | ||
{ "000", 0, 0.0 }, | ||
{ "-0", 0, -0.0 }, | ||
{ "-000", 0, -0.0 }, | ||
{ "0,", 0, 0.0 }, | ||
{ "-0,", 0, -0.0 }, | ||
{ "0,0", 0, 0.0 }, | ||
{ "-0,0", 0, -0.0 }, | ||
{ "0e-10", 0, 0.0 }, | ||
{ "-0e-10", 0, -0.0 }, | ||
{ "0,e-10", 0, 0.0 }, | ||
{ "-0,e-10", 0, -0.0 }, | ||
{ "0,0e-10", 0, 0.0 }, | ||
{ "-0,0e-10", 0, -0.0 }, | ||
{ "0e-1000000", 0, 0.0 }, | ||
{ "-0e-1000000", 0, -0.0 }, | ||
{ "0,0e-1000000", 0, 0.0 }, | ||
{ "-0,0e-1000000", 0, -0.0 }, | ||
{ "0", 1, 0.0 }, | ||
{ "000", 1, 0.0 }, | ||
{ "-0", 1, -0.0 }, | ||
{ "-000", 1, -0.0 }, | ||
{ "0e-10", 1, 0.0 }, | ||
{ "-0e-10", 1, -0.0 }, | ||
{ "0e-1000000", 1, 0.0 }, | ||
{ "-0e-1000000", 1, -0.0 }, | ||
{ "000"NBSP"000"NBSP"000", 1, 0.0 }, | ||
{ "-000"NBSP"000"NBSP"000", 1, -0.0 } | ||
}; | ||
#define NTESTS (sizeof (tests) / sizeof (tests[0])) | ||
|
||
|
||
static int | ||
do_test (void) | ||
{ | ||
if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL) | ||
{ | ||
puts ("could not set locale"); | ||
return 1; | ||
} | ||
|
||
int status = 0; | ||
|
||
for (int i = 0; i < NTESTS; ++i) | ||
{ | ||
char *ep; | ||
double r; | ||
|
||
if (tests[i].group) | ||
r = __strtod_internal (tests[i].in, &ep, 1); | ||
else | ||
r = strtod (tests[i].in, &ep); | ||
|
||
if (*ep != '\0') | ||
{ | ||
printf ("%d: got rest string \"%s\", expected \"\"\n", i, ep); | ||
status = 1; | ||
} | ||
|
||
if (r != tests[i].expected | ||
|| copysign (10.0, r) != copysign (10.0, tests[i].expected)) | ||
{ | ||
printf ("%d: got wrong results %g, expected %g\n", | ||
i, r, tests[i].expected); | ||
status = 1; | ||
} | ||
} | ||
|
||
return status; | ||
} | ||
|
||
#define TEST_FUNCTION do_test () | ||
#include "../test-skeleton.c" |