diff options
author | jofret | 2007-04-20 08:29:01 +0000 |
---|---|---|
committer | jofret | 2007-04-20 08:29:01 +0000 |
commit | 8e7ea9e904a0e9c5760d2b05de5b3f0af31785de (patch) | |
tree | 8bbc6d569d015b1ace8634923366776c18c200fb /src/elementaryFunctions/acos | |
parent | 619b9b1cbc757d4a03984b49fbd8dc6e6c54b638 (diff) | |
download | scilab2c-8e7ea9e904a0e9c5760d2b05de5b3f0af31785de.tar.gz scilab2c-8e7ea9e904a0e9c5760d2b05de5b3f0af31785de.tar.bz2 scilab2c-8e7ea9e904a0e9c5760d2b05de5b3f0af31785de.zip |
Adding automated tests.
Diffstat (limited to 'src/elementaryFunctions/acos')
-rw-r--r-- | src/elementaryFunctions/acos/Makefile.am | 23 | ||||
-rw-r--r-- | src/elementaryFunctions/acos/Makefile.in | 142 | ||||
-rw-r--r-- | src/elementaryFunctions/acos/testAcos.c | 150 | ||||
-rw-r--r-- | src/elementaryFunctions/acos/testAcos.h | 40 |
4 files changed, 344 insertions, 11 deletions
diff --git a/src/elementaryFunctions/acos/Makefile.am b/src/elementaryFunctions/acos/Makefile.am index e5dd6130..38541f43 100644 --- a/src/elementaryFunctions/acos/Makefile.am +++ b/src/elementaryFunctions/acos/Makefile.am @@ -5,7 +5,7 @@ ## Made by Bruno JOFRET <bruno.jofret@inria.fr> ## ## Started on Fri Jan 5 10:19:16 2007 jofret -## Last update Sun Mar 25 21:02:08 2007 bruno +## Last update Fri Apr 20 10:26:22 2007 jofret ## ## Copyright INRIA 2007 ## @@ -31,3 +31,24 @@ SRC = sacoss.c \ zacosa.c HEAD = ../includes/acos.h + +#### +# Checking Part +#### + +check_INCLUDES = -I $(top_builddir)/elementaryFunctions/includes \ + -I $(top_builddir)/type + +check_PROGRAMS = testAcos + +TESTS = testAcos + +# +# -*- Acosine Tests -*- +# +testAcos_SOURCES = testAcos.c +testAcos_CFLAGS = $(check_INCLUDES) +testAcos_LDADD = $(top_builddir)/lib/libDoubleComplex.a \ + $(top_builddir)/lib/libFloatComplex.a \ + $(top_builddir)/lib/libAcos.a \ + @LIBMATH@
\ No newline at end of file diff --git a/src/elementaryFunctions/acos/Makefile.in b/src/elementaryFunctions/acos/Makefile.in index 7a682d79..b8a06dad 100644 --- a/src/elementaryFunctions/acos/Makefile.in +++ b/src/elementaryFunctions/acos/Makefile.in @@ -36,6 +36,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ +check_PROGRAMS = testAcos$(EXEEXT) subdir = elementaryFunctions/acos DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -65,6 +66,11 @@ am__objects_2 = sacoss.$(OBJEXT) dacoss.$(OBJEXT) cacoss.$(OBJEXT) \ cacosa.$(OBJEXT) zacosa.$(OBJEXT) am_libAcos_a_OBJECTS = $(am__objects_1) $(am__objects_2) libAcos_a_OBJECTS = $(am_libAcos_a_OBJECTS) +am_testAcos_OBJECTS = testAcos-testAcos.$(OBJEXT) +testAcos_OBJECTS = $(am_testAcos_OBJECTS) +testAcos_DEPENDENCIES = $(top_builddir)/lib/libDoubleComplex.a \ + $(top_builddir)/lib/libFloatComplex.a \ + $(top_builddir)/lib/libAcos.a DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/includes depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__depfiles_maybe = depfiles @@ -72,8 +78,8 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(libAcos_a_SOURCES) -DIST_SOURCES = $(libAcos_a_SOURCES) +SOURCES = $(libAcos_a_SOURCES) $(testAcos_SOURCES) +DIST_SOURCES = $(libAcos_a_SOURCES) $(testAcos_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -189,6 +195,25 @@ SRC = sacoss.c \ zacosa.c HEAD = ../includes/acos.h + +#### +# Checking Part +#### +check_INCLUDES = -I $(top_builddir)/elementaryFunctions/includes \ + -I $(top_builddir)/type + +TESTS = testAcos + +# +# -*- Acosine Tests -*- +# +testAcos_SOURCES = testAcos.c +testAcos_CFLAGS = $(check_INCLUDES) +testAcos_LDADD = $(top_builddir)/lib/libDoubleComplex.a \ + $(top_builddir)/lib/libFloatComplex.a \ + $(top_builddir)/lib/libAcos.a \ + @LIBMATH@ + all: all-am .SUFFIXES: @@ -259,6 +284,12 @@ libAcos.a: $(libAcos_a_OBJECTS) $(libAcos_a_DEPENDENCIES) $(libAcos_a_AR) libAcos.a $(libAcos_a_OBJECTS) $(libAcos_a_LIBADD) $(RANLIB) libAcos.a +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +testAcos$(EXEEXT): $(testAcos_OBJECTS) $(testAcos_DEPENDENCIES) + @rm -f testAcos$(EXEEXT) + $(LINK) $(testAcos_LDFLAGS) $(testAcos_OBJECTS) $(testAcos_LDADD) $(LIBS) + mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -271,6 +302,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dacoss.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sacosa.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sacoss.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testAcos-testAcos.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zacosa.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zacoss.Po@am__quote@ @@ -287,6 +319,20 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +testAcos-testAcos.o: testAcos.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testAcos_CFLAGS) $(CFLAGS) -MT testAcos-testAcos.o -MD -MP -MF "$(DEPDIR)/testAcos-testAcos.Tpo" -c -o testAcos-testAcos.o `test -f 'testAcos.c' || echo '$(srcdir)/'`testAcos.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/testAcos-testAcos.Tpo" "$(DEPDIR)/testAcos-testAcos.Po"; else rm -f "$(DEPDIR)/testAcos-testAcos.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testAcos.c' object='testAcos-testAcos.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testAcos_CFLAGS) $(CFLAGS) -c -o testAcos-testAcos.o `test -f 'testAcos.c' || echo '$(srcdir)/'`testAcos.c + +testAcos-testAcos.obj: testAcos.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testAcos_CFLAGS) $(CFLAGS) -MT testAcos-testAcos.obj -MD -MP -MF "$(DEPDIR)/testAcos-testAcos.Tpo" -c -o testAcos-testAcos.obj `if test -f 'testAcos.c'; then $(CYGPATH_W) 'testAcos.c'; else $(CYGPATH_W) '$(srcdir)/testAcos.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/testAcos-testAcos.Tpo" "$(DEPDIR)/testAcos-testAcos.Po"; else rm -f "$(DEPDIR)/testAcos-testAcos.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testAcos.c' object='testAcos-testAcos.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testAcos_CFLAGS) $(CFLAGS) -c -o testAcos-testAcos.obj `if test -f 'testAcos.c'; then $(CYGPATH_W) 'testAcos.c'; else $(CYGPATH_W) '$(srcdir)/testAcos.c'; fi` uninstall-info-am: ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) @@ -337,6 +383,79 @@ GTAGS: distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ @@ -365,6 +484,8 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(LIBRARIES) installdirs: @@ -397,8 +518,8 @@ maintainer-clean-generic: @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-generic clean-instLIBRARIES clean-noinstLIBRARIES \ - mostlyclean-am +clean-am: clean-checkPROGRAMS clean-generic clean-instLIBRARIES \ + clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) @@ -445,12 +566,13 @@ ps-am: uninstall-am: uninstall-info-am uninstall-instLIBRARIES -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-instLIBRARIES clean-noinstLIBRARIES ctags distclean \ - distclean-compile distclean-generic distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-exec install-exec-am \ - install-info install-info-am install-instLIBRARIES install-man \ +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-instLIBRARIES \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-instLIBRARIES install-man \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ diff --git a/src/elementaryFunctions/acos/testAcos.c b/src/elementaryFunctions/acos/testAcos.c new file mode 100644 index 00000000..3dc5e3c0 --- /dev/null +++ b/src/elementaryFunctions/acos/testAcos.c @@ -0,0 +1,150 @@ +/* +** -*- C -*- +** +** testAcos.c +** Made by Bruno JOFRET <bruno.jofret@inria.fr> +** +** Started on Fri Dec 8 15:05:44 2006 jofret +** Last update Fri Apr 20 10:24:42 2007 jofret +** +** Copyright INRIA 2006 +*/ + +#include "testAcos.h" + +void sacossTest(void) { + printf(">> Float scalar\n"); + printf("sacoss(0) = %f\n", sacoss((float) 0)); + printf("sacoss(PI) = %f\n", sacoss(PI)); + printf("sacoss(PI/2) = %f\n", sacoss(PI/2)); + printf("sacoss(PI/3) = %f\n", sacoss(PI/3)); + printf("sacoss(PI/4) = %f\n", sacoss(PI/4)); + printf("sacoss(PI/6) = %f\n", sacoss(PI/6)); + printf("sacoss(-PI) = %f\n", sacoss(-PI)); + printf("sacoss(-PI/2) = %f\n", sacoss(-PI/2)); + printf("sacoss(-PI/3) = %f\n", sacoss(-PI/3)); + printf("sacoss(-PI/4) = %f\n", sacoss(-PI/4)); + printf("sacoss(-PI/6) = %f\n", sacoss(-PI/6)); +} + +void dacossTest(void) { + printf(">> Double scalar\n"); + printf("dacoss(0) = %e\n", dacoss((double) 0)); + printf("dacoss(PI) = %e\n", dacoss(PI)); + printf("dacoss(PI/2) = %e\n", dacoss(PI/2)); + printf("dacoss(PI/3) = %e\n", dacoss(PI/3)); + printf("dacoss(PI/4) = %e\n", dacoss(PI/4)); + printf("dacoss(PI/6) = %e\n", dacoss(PI/6)); + printf("dacoss(-PI) = %e\n", dacoss(-PI)); + printf("dacoss(-PI/2) = %e\n", dacoss(-PI/2)); + printf("dacoss(-PI/3) = %e\n", dacoss(-PI/3)); + printf("dacoss(-PI/4) = %e\n", dacoss(-PI/4)); + printf("dacoss(-PI/6) = %e\n", dacoss(-PI/6)); +} + +void cacossTest(void) { + floatComplex pi_pi = FloatComplex(PI, PI); + floatComplex pi_2_pi_2 = FloatComplex(PI/2, PI/2); + floatComplex pi_2_pi_3 = FloatComplex(PI/2, PI/3); + floatComplex pi_2_pi_4 = FloatComplex(PI/2, PI/4); + floatComplex out; + + printf(">> Float Complex scalar\n"); + out = cacoss(pi_pi); + printf("cacoss(PI + I*PI) = %f + I * %f\n", creals(out), cimags(out)); + out = cacoss(pi_2_pi_2); + printf("cacoss(PI/2 + I*PI/2) = %f + I * %f\n", creals(out), cimags(out)); + out = cacoss(pi_2_pi_3); + printf("cacoss(PI/2 + I*PI/3) = %f + I * %f\n", creals(out), cimags(out)); + out = cacoss(pi_2_pi_4); + printf("cacoss(PI/2 + I*PI/4) = %f + I * %f\n", creals(out), cimags(out)); +} + +void zacossTest(void) { + doubleComplex pi_pi = DoubleComplex(PI, PI); + doubleComplex pi_2_pi_2 = DoubleComplex(PI/2, PI/2); + doubleComplex pi_2_pi_3 = DoubleComplex(PI/2, PI/3); + doubleComplex pi_2_pi_4 = DoubleComplex(PI/2, PI/4); + doubleComplex out; + + printf(">> Double Complex scalar\n"); + out = zacoss(pi_pi); + printf("zacoss(PI + I*PI) = %e + I * %e\n", zreals(out), zimags(out)); + out = zacoss(pi_2_pi_2); + printf("zacoss(PI/2 + I*PI/2) = %e + I * %e\n", zreals(out), zimags(out)); + out = zacoss(pi_2_pi_3); + printf("zacoss(PI/2 + I*PI/3) = %e + I * %e\n", zreals(out), zimags(out)); + out = zacoss(pi_2_pi_4); + printf("zacoss(PI/2 + I*PI/4) = %e + I * %e\n", zreals(out), zimags(out)); +} + +void sacosaTest(void) { + float out[5]; + float in[5] = {PI, PI/2, PI/3, PI/4, PI/6}; + int i = 0; + + printf(">> Float array\n"); + sacosa(in, out, 5); + for (i = 0 ; i < 5 ; ++i) + printf("sacosa(array) = %f\n", out[i]); +} + +void dacosaTest(void) { + double out[5]; + double in[5] = {PI, PI/2, PI/3, PI/4, PI/6}; + int i = 0; + + printf(">> Double Array\n"); + dacosa(in, out, 5); + for (i = 0 ; i < 5 ; ++i) + printf("sacosa(array) = %f\n", out[i]); + +} + +void cacosaTest(void) { + floatComplex pi_pi = FloatComplex(PI, PI); + floatComplex pi_2_pi_2 = FloatComplex(PI/2, PI/2); + floatComplex pi_2_pi_3 = FloatComplex(PI/2, PI/3); + floatComplex pi_2_pi_4 = FloatComplex(PI/2, PI/4); + floatComplex in[4] = {pi_pi, pi_2_pi_2, pi_2_pi_3, pi_2_pi_4}; + floatComplex out[4]; + int i = 0; + + cacosa(in, out, 4); + printf(">> Float Complex Array\n"); + for (i = 0 ; i < 4 ; ++i) + printf("cacosa(array) = %e + I * %e\n", creals(out[i]), cimags(out[i])); +} + +void zacosaTest(void) { + doubleComplex pi_pi = DoubleComplex(PI, PI); + doubleComplex pi_2_pi_2 = DoubleComplex(PI/2, PI/2); + doubleComplex pi_2_pi_3 = DoubleComplex(PI/2, PI/3); + doubleComplex pi_2_pi_4 = DoubleComplex(PI/2, PI/4); + doubleComplex in[4] = {pi_pi, pi_2_pi_2, pi_2_pi_3, pi_2_pi_4 }; + doubleComplex out[4]; + int i = 0; + + zacosa(in, out, 4); + printf(">> Double Complex Array\n"); + for (i = 0 ; i < 4 ; ++i) + printf("zacosa(array) = %e + I * %e\n", zreals(out[i]), zimags(out[i])); +} + +int testAcos(void) { + printf("\n>>>> ArcCosine Tests\n"); + sacossTest(); + dacossTest(); + cacossTest(); + zacossTest(); + sacosaTest(); + dacosaTest(); + cacosaTest(); + zacosaTest(); + return 0; +} + +int main(void) { + assert(testAcos() == 0); + return 0; +} diff --git a/src/elementaryFunctions/acos/testAcos.h b/src/elementaryFunctions/acos/testAcos.h new file mode 100644 index 00000000..3502df85 --- /dev/null +++ b/src/elementaryFunctions/acos/testAcos.h @@ -0,0 +1,40 @@ +/* +** -*- C -*- +** +** testAcos.h +** Made by Bruno JOFRET <bruno.jofret@inria.fr> +** +** Started on Mon Mar 26 16:33:11 2007 jofret +** Last update Fri Apr 20 10:33:19 2007 jofret +** +** Copyright INRIA 2007 +*/ + +#ifndef _TESTACOS_H_ +#define _TESTACOS_H_ + +#include <stdio.h> +#include <assert.h> +#include "acos.h" +#include "constant.h" + + +void sacossTest(void); + +void dacossTest(void); + +void cacossTest(void); + +void zacossTest(void); + +void sacosaTest(void); + +void dacosaTest(void); + +void cacosaTest(void); + +void zacosaTest(void); + +int testAcos(void); + +#endif /* ! _TESTACOS_H_ */ |