From de58fd98f4ede3c8da870f8df3934735ee1a3531 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 25 Jan 2010 02:11:59 +0100 Subject: [PATCH] Tests for module 'logb'. --- ChangeLog | 4 ++++ modules/logb-tests | 13 ++++++++++++ tests/test-logb.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 modules/logb-tests create mode 100644 tests/test-logb.c diff --git a/ChangeLog b/ChangeLog index f0fee6286..a85518976 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-01-24 Bruno Haible + Tests for module 'logb'. + * modules/logb-tests: New file. + * tests/test-logb.c: New file. + Tests for module 'log1p'. * modules/log1p-tests: New file. * tests/test-log1p.c: New file. diff --git a/modules/logb-tests b/modules/logb-tests new file mode 100644 index 000000000..f9490702f --- /dev/null +++ b/modules/logb-tests @@ -0,0 +1,13 @@ +Files: +tests/test-logb.c +tests/signature.h +tests/macros.h + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-logb +check_PROGRAMS += test-logb +test_logb_LDADD = $(LDADD) @LOGB_LIBM@ diff --git a/tests/test-logb.c b/tests/test-logb.c new file mode 100644 index 000000000..8b7a612d8 --- /dev/null +++ b/tests/test-logb.c @@ -0,0 +1,62 @@ +/* Test of logb() function. + Copyright (C) 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2010. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (logb, double, (double)); + +#include + +#include "macros.h" + +volatile double x; +double y; + +int +main () +{ + /* Some particular values. */ + x = 0.6; + y = logb (x); + ASSERT (y == -1.0); + + x = 1.2; + y = logb (x); + ASSERT (y == 0.0); + + x = 2.1; + y = logb (x); + ASSERT (y == 1.0); + + x = 3.9; + y = logb (x); + ASSERT (y == 1.0); + + x = 4.0; + y = logb (x); + ASSERT (y == (FLT_RADIX == 2 ? 2.0 : 1.0)); + + x = 0.25; + y = logb (x); + ASSERT (y == (FLT_RADIX == 2 ? -2.0 : -1.0)); + + return 0; +} -- 2.11.0