humble beginnings of regression tests for libm functions: test for

a longstanding bug in round()/roundf() which I will pull in a fix
for (from FreeBSD) in a minute
This commit is contained in:
drochner 2007-08-21 19:52:36 +00:00
parent bd627359dd
commit f0a00b4ec9
4 changed files with 42 additions and 2 deletions

View File

@ -1,8 +1,8 @@
# $NetBSD: Makefile,v 1.19 2007/05/30 19:49:49 tls Exp $
# $NetBSD: Makefile,v 1.20 2007/08/21 19:52:36 drochner Exp $
.include <bsd.own.mk>
SUBDIR+= csu libc libevent libposix libpthread librt libutil
SUBDIR+= csu libc libevent libm libposix libpthread librt libutil
.if (${MACHINE_CPU} != "alpha" && \
${MACHINE_CPU} != "mips" && \

View File

@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2007/08/21 19:52:36 drochner Exp $
SUBDIR= round
.include <bsd.subdir.mk>

View File

@ -0,0 +1,10 @@
# $NetBSD: Makefile,v 1.1 2007/08/21 19:52:36 drochner Exp $
PROG= round
LDADD+= -lm
NOMAN=
regress: $(PROG)
./$(PROG)
.include <bsd.prog.mk>

View File

@ -0,0 +1,25 @@
/* $NetBSD: round.c,v 1.1 2007/08/21 19:52:36 drochner Exp $ */
#include <math.h>
/*
* This tests for a bug in the initial implementation where precision
* was lost in an internal substraction, leading to rounding
* into the wrong direction.
*/
/* 0.5 - EPSILON */
#define VAL 0x0.7ffffffffffffcp0
#define VALF 0x0.7fffff8p0
int main()
{
double a = VAL, b, c;
float af = VALF, bf, cf;
b = round(a);
bf = roundf(af);
c = round(-a);
cf = roundf(-af);
return (b != 0 || bf != 0 || c != 0 || cf != 0);
}