From d6220e9ee38c1c9285221b023346201ec5f511b3 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 11 Jan 2007 21:51:00 +0000 Subject: Include errno.h. Change main() to do_test(). Define TEST_FUNCTION. Include test-skeleton.c. (do_test): Check errno and exit(0) if ENOSYS. --- stdlib/tst-strtod4.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 stdlib/tst-strtod4.c (limited to 'stdlib/tst-strtod4.c') diff --git a/stdlib/tst-strtod4.c b/stdlib/tst-strtod4.c new file mode 100644 index 0000000000..2d9d54c944 --- /dev/null +++ b/stdlib/tst-strtod4.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include + +#define NBSP "\xc2\xa0" + +static const struct +{ + const char *in; + const char *out; + double expected; +} tests[] = + { + { "000"NBSP"000"NBSP"000", "", 0.0 }, + { "1"NBSP"000"NBSP"000,5x", "x", 1000000.5 } + }; +#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 = __strtod_internal (tests[i].in, &ep, 1); + + if (strcmp (ep, tests[i].out) != 0) + { + printf ("%d: got rest string \"%s\", expected \"%s\"\n", + i, ep, tests[i].out); + status = 1; + } + + if (r != 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" -- cgit 1.4.1