From b111751208a94882547ae748c16e7978fa7226b6 Mon Sep 17 00:00:00 2001 From: otto <> Date: Fri, 29 Sep 2006 11:00:24 +0000 Subject: add strtod() underflow test --- src/regress/lib/libc/Makefile | 4 ++-- src/regress/lib/libc/strtod/Makefile | 5 +++++ src/regress/lib/libc/strtod/strtodtest.c | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/regress/lib/libc/strtod/Makefile create mode 100644 src/regress/lib/libc/strtod/strtodtest.c (limited to 'src') diff --git a/src/regress/lib/libc/Makefile b/src/regress/lib/libc/Makefile index a6d3d766b1..04970c7e16 100644 --- a/src/regress/lib/libc/Makefile +++ b/src/regress/lib/libc/Makefile @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile,v 1.23 2006/03/25 20:28:19 otto Exp $ +# $OpenBSD: Makefile,v 1.24 2006/09/29 11:00:24 otto Exp $ SUBDIR+= _setjmp alloca atexit db getaddrinfo getcap getopt_long hsearch longjmp SUBDIR+= locale malloc SUBDIR+= netdb popen regex setjmp setjmp-signal sigreturn sigsetjmp -SUBDIR+= sprintf strerror strtonum telldir time vis +SUBDIR+= sprintf strerror strtod strtonum telldir time vis .if (${MACHINE_ARCH} != "vax") SUBDIR+= ieeefp diff --git a/src/regress/lib/libc/strtod/Makefile b/src/regress/lib/libc/strtod/Makefile new file mode 100644 index 0000000000..030c0e7f56 --- /dev/null +++ b/src/regress/lib/libc/strtod/Makefile @@ -0,0 +1,5 @@ +# $OpenBSD: Makefile,v 1.1 2006/09/29 11:00:24 otto Exp $ + +PROG= strtodtest + +.include diff --git a/src/regress/lib/libc/strtod/strtodtest.c b/src/regress/lib/libc/strtod/strtodtest.c new file mode 100644 index 0000000000..0291365a75 --- /dev/null +++ b/src/regress/lib/libc/strtod/strtodtest.c @@ -0,0 +1,22 @@ +/* $OpenBSD: strtodtest.c,v 1.1 2006/09/29 11:00:24 otto Exp $ */ +/* Public domain, Otto Moerbeek , 2006. */ + +#include +#include +#include + +/* + * Checks if strtod() reports underflow. + */ + +int +main() +{ + char *tmp="0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002"; + double d; + + d = strtod(tmp, NULL); + if (errno != ERANGE) + errx(1, "errno = %d", errno); + return (0); +} -- cgit v1.2.3-55-g6feb