diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2006-09-29 11:00:25 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2006-09-29 11:00:25 +0000 |
commit | 743ad0da7030a75abed08cdae1442be8689032f3 (patch) | |
tree | e7aceb37a100529a80d4ab15c7460096e290da5b | |
parent | 3c609650dcf9686023a61577999329c56f564563 (diff) |
add strtod() underflow test
-rw-r--r-- | regress/lib/libc/Makefile | 4 | ||||
-rw-r--r-- | regress/lib/libc/strtod/Makefile | 5 | ||||
-rw-r--r-- | regress/lib/libc/strtod/strtodtest.c | 22 |
3 files changed, 29 insertions, 2 deletions
diff --git a/regress/lib/libc/Makefile b/regress/lib/libc/Makefile index a6d3d766b1c..04970c7e163 100644 --- a/regress/lib/libc/Makefile +++ b/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/regress/lib/libc/strtod/Makefile b/regress/lib/libc/strtod/Makefile new file mode 100644 index 00000000000..030c0e7f56c --- /dev/null +++ b/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 <bsd.regress.mk> diff --git a/regress/lib/libc/strtod/strtodtest.c b/regress/lib/libc/strtod/strtodtest.c new file mode 100644 index 00000000000..0291365a757 --- /dev/null +++ b/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 <otto@drijf.net>, 2006. */ + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> + +/* + * 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); +} |