From add94c7ea454202a01c5feb96c7e9131f82d7a46 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Fri, 1 Mar 2019 20:17:09 -0500 Subject: skeleton of tests --- Makefile | 2 +- main.c | 4 ++-- math.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 math.c diff --git a/Makefile b/Makefile index d84925d..5a87be0 100644 --- a/Makefile +++ b/Makefile @@ -7,13 +7,13 @@ LDFLAGS=-L$(LIBDIR) $(LIBS) TESTOBJS=main.o \ assert.o \ - complex.o \ ctype.o \ errno.o \ float.o \ iso646.o \ limits.o \ locale.o \ + math.o \ signal.o \ stdbool.o \ stddef.o \ diff --git a/main.c b/main.c index fdcad73..23dbc18 100644 --- a/main.c +++ b/main.c @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) } } - test_complex_h(); + /* test_complex_h(); */ test_ctype_h(); test_errno_h(); /* test_fenv_h(); */ @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) test_iso646_h(); test_limits_h(); test_locale_h(); - /* test_math_h(); */ + test_math_h(); /* test_setjmp_h(); */ test_signal_h(); /* test_stdalign_h(); */ diff --git a/math.c b/math.c new file mode 100644 index 0000000..5120b93 --- /dev/null +++ b/math.c @@ -0,0 +1,37 @@ +#include +#include "test.h" + +void test_math_h(void) +{ + int iexp = 1; + double iptr = 0; + + testing_header("math.h"); + + test_defined(HUGE_VAL); + test_double(acos(1), 0); + test_double(asin(1), 0); + test_double(atan(1), 0); + test_double(atan2(1, 1), 0); + test_double(cos(1), 0); + test_double(sin(1), 0); + test_double(tan(1), 0); + test_double(cosh(1), 0); + test_double(sinh(1), 0); + test_double(tanh(1), 0); + test_double(exp(1), 0); + test_double(frexp(1, &iexp), 0); + test_double(ldexp(1, iexp), 0); + test_double(log(2.4), 1); + test_double(log10(10), 1); + test_double(log10(100), 2); + test_double(modf(1, &iptr), 0); + test_double(pow(2, 2), 4); + test_double(sqrt(100), 10); + test_double(ceil(0.1), 1); + test_double(fabs(-1.0), 1.0); + test_double(floor(0.9), 0); + test_double(fmod(1, 1), 0); + + testing_end(); +} -- cgit v1.2.1