xref: /openbsd-src/regress/lib/libc/strtod/strtodtest.c (revision 9ae1fb7f33942b61978ae72fb1e634571e1884f8)
1*9ae1fb7fSjsg /*	$OpenBSD: strtodtest.c,v 1.2 2017/02/25 07:28:32 jsg Exp $	*/
2775a0275Sotto /* Public domain, Otto Moerbeek <otto@drijf.net>, 2006. */
3775a0275Sotto 
4775a0275Sotto #include <stdio.h>
5775a0275Sotto #include <stdlib.h>
6775a0275Sotto #include <errno.h>
7*9ae1fb7fSjsg #include <err.h>
8775a0275Sotto 
9775a0275Sotto /*
10775a0275Sotto  * Checks if strtod() reports underflow.
11775a0275Sotto  */
12775a0275Sotto 
13775a0275Sotto int
main()14775a0275Sotto main()
15775a0275Sotto {
16775a0275Sotto 	char *tmp="0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002";
17775a0275Sotto 	double d;
18775a0275Sotto 
19775a0275Sotto 	d = strtod(tmp, NULL);
20775a0275Sotto 	if (errno != ERANGE)
21775a0275Sotto 		errx(1, "errno = %d", errno);
22775a0275Sotto 	return (0);
23775a0275Sotto }
24