diff options
author | jofret | 2005-03-16 02:11:13 +0000 |
---|---|---|
committer | jofret | 2005-03-16 02:11:13 +0000 |
commit | 50ca7629cb63146ce95eb19b48dd528e788c4d14 (patch) | |
tree | c063eed06d3213ce7205f2c308c2a73c4de6d38c | |
parent | 02f1ba9e28fbc94eedfdd7bcfee164eceeb0bc52 (diff) | |
download | scilab2c-50ca7629cb63146ce95eb19b48dd528e788c4d14.tar.gz scilab2c-50ca7629cb63146ce95eb19b48dd528e788c4d14.tar.bz2 scilab2c-50ca7629cb63146ce95eb19b48dd528e788c4d14.zip |
Better floatvs. double management. Enable Psycho warnings.
-rw-r--r-- | src/auxiliaryFunctions/abs/Makefile.am | 24 | ||||
-rw-r--r-- | src/auxiliaryFunctions/abs/Makefile.in | 93 | ||||
-rw-r--r-- | src/auxiliaryFunctions/abs/testAbs.c | 154 | ||||
-rw-r--r-- | src/auxiliaryFunctions/abs/testDoubleAbs.c | 93 | ||||
-rw-r--r-- | src/auxiliaryFunctions/abs/testFloatAbs.c | 93 |
5 files changed, 263 insertions, 194 deletions
diff --git a/src/auxiliaryFunctions/abs/Makefile.am b/src/auxiliaryFunctions/abs/Makefile.am index 87e5329a..60291ad5 100644 --- a/src/auxiliaryFunctions/abs/Makefile.am +++ b/src/auxiliaryFunctions/abs/Makefile.am @@ -39,17 +39,23 @@ check_INCLUDES = -I $(top_builddir)/auxiliaryFunctions/includes \ -I $(top_builddir)/elementaryFunctions/includes \ -I $(top_builddir)/type -check_PROGRAMS = testAbs +check_LDADD = $(top_builddir)/type/libDoubleComplex.la \ + $(top_builddir)/type/libFloatComplex.la \ + $(top_builddir)/auxiliaryFunctions/abs/libAbs.la \ + $(top_builddir)/elementaryFunctions/sqrt/libSqrt.la \ + @LIBMATH@ + +check_PROGRAMS = testFloatAbs testDoubleAbs -TESTS = testAbs +TESTS = testFloatAbs testDoubleAbs # # -*- Abs Tests -*- # -testAbs_SOURCES = testAbs.c -testAbs_CFLAGS = $(check_INCLUDES) -testAbs_LDADD = $(top_builddir)/type/libDoubleComplex.la \ - $(top_builddir)/type/libFloatComplex.la \ - $(top_builddir)/auxiliaryFunctions/abs/libAbs.la \ - $(top_builddir)/elementaryFunctions/sqrt/libSqrt.la \ - @LIBMATH@ +testFloatAbs_SOURCES = testFloatAbs.c +testFloatAbs_CFLAGS = $(check_INCLUDES) +testFloatAbs_LDADD = $(check_LDADD) + +testDoubleAbs_SOURCES = testDoubleAbs.c +testDoubleAbs_CFLAGS = $(check_INCLUDES) +testDoubleAbs_LDADD = $(check_LDADD) diff --git a/src/auxiliaryFunctions/abs/Makefile.in b/src/auxiliaryFunctions/abs/Makefile.in index 6e2e47cb..d3ac9681 100644 --- a/src/auxiliaryFunctions/abs/Makefile.in +++ b/src/auxiliaryFunctions/abs/Makefile.in @@ -32,8 +32,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -check_PROGRAMS = testAbs$(EXEEXT) -TESTS = testAbs$(EXEEXT) +check_PROGRAMS = testFloatAbs$(EXEEXT) testDoubleAbs$(EXEEXT) +TESTS = testFloatAbs$(EXEEXT) testDoubleAbs$(EXEEXT) subdir = auxiliaryFunctions/abs DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -62,15 +62,22 @@ libAbs_la_OBJECTS = $(am_libAbs_la_OBJECTS) libAbs_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libAbs_la_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -am_testAbs_OBJECTS = testAbs-testAbs.$(OBJEXT) -testAbs_OBJECTS = $(am_testAbs_OBJECTS) -testAbs_DEPENDENCIES = $(top_builddir)/type/libDoubleComplex.la \ +am_testDoubleAbs_OBJECTS = testDoubleAbs-testDoubleAbs.$(OBJEXT) +testDoubleAbs_OBJECTS = $(am_testDoubleAbs_OBJECTS) +am__DEPENDENCIES_1 = $(top_builddir)/type/libDoubleComplex.la \ $(top_builddir)/type/libFloatComplex.la \ $(top_builddir)/auxiliaryFunctions/abs/libAbs.la \ $(top_builddir)/elementaryFunctions/sqrt/libSqrt.la -testAbs_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(testAbs_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ +testDoubleAbs_DEPENDENCIES = $(am__DEPENDENCIES_1) +testDoubleAbs_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(testDoubleAbs_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am_testFloatAbs_OBJECTS = testFloatAbs-testFloatAbs.$(OBJEXT) +testFloatAbs_OBJECTS = $(am_testFloatAbs_OBJECTS) +testFloatAbs_DEPENDENCIES = $(am__DEPENDENCIES_1) +testFloatAbs_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(testFloatAbs_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I. -I$(top_builddir)/includes@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__depfiles_maybe = depfiles @@ -83,8 +90,10 @@ CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = $(libAbs_la_SOURCES) $(testAbs_SOURCES) -DIST_SOURCES = $(libAbs_la_SOURCES) $(testAbs_SOURCES) +SOURCES = $(libAbs_la_SOURCES) $(testDoubleAbs_SOURCES) \ + $(testFloatAbs_SOURCES) +DIST_SOURCES = $(libAbs_la_SOURCES) $(testDoubleAbs_SOURCES) \ + $(testFloatAbs_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -221,18 +230,22 @@ check_INCLUDES = -I $(top_builddir)/auxiliaryFunctions/includes \ -I $(top_builddir)/elementaryFunctions/includes \ -I $(top_builddir)/type - -# -# -*- Abs Tests -*- -# -testAbs_SOURCES = testAbs.c -testAbs_CFLAGS = $(check_INCLUDES) -testAbs_LDADD = $(top_builddir)/type/libDoubleComplex.la \ +check_LDADD = $(top_builddir)/type/libDoubleComplex.la \ $(top_builddir)/type/libFloatComplex.la \ $(top_builddir)/auxiliaryFunctions/abs/libAbs.la \ $(top_builddir)/elementaryFunctions/sqrt/libSqrt.la \ @LIBMATH@ + +# +# -*- Abs Tests -*- +# +testFloatAbs_SOURCES = testFloatAbs.c +testFloatAbs_CFLAGS = $(check_INCLUDES) +testFloatAbs_LDADD = $(check_LDADD) +testDoubleAbs_SOURCES = testDoubleAbs.c +testDoubleAbs_CFLAGS = $(check_INCLUDES) +testDoubleAbs_LDADD = $(check_LDADD) all: all-am .SUFFIXES: @@ -302,9 +315,12 @@ clean-checkPROGRAMS: echo " rm -f $$p $$f"; \ rm -f $$p $$f ; \ done -testAbs$(EXEEXT): $(testAbs_OBJECTS) $(testAbs_DEPENDENCIES) - @rm -f testAbs$(EXEEXT) - $(testAbs_LINK) $(testAbs_OBJECTS) $(testAbs_LDADD) $(LIBS) +testDoubleAbs$(EXEEXT): $(testDoubleAbs_OBJECTS) $(testDoubleAbs_DEPENDENCIES) + @rm -f testDoubleAbs$(EXEEXT) + $(testDoubleAbs_LINK) $(testDoubleAbs_OBJECTS) $(testDoubleAbs_LDADD) $(LIBS) +testFloatAbs$(EXEEXT): $(testFloatAbs_OBJECTS) $(testFloatAbs_DEPENDENCIES) + @rm -f testFloatAbs$(EXEEXT) + $(testFloatAbs_LINK) $(testFloatAbs_OBJECTS) $(testFloatAbs_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -320,7 +336,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libAbs_la-sabss.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libAbs_la-zabsa.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libAbs_la-zabss.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testAbs-testAbs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testDoubleAbs-testDoubleAbs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testFloatAbs-testFloatAbs.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -399,19 +416,33 @@ libAbs_la-zabsa.lo: zabsa.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libAbs_la_CFLAGS) $(CFLAGS) -c -o libAbs_la-zabsa.lo `test -f 'zabsa.c' || echo '$(srcdir)/'`zabsa.c -testAbs-testAbs.o: testAbs.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testAbs_CFLAGS) $(CFLAGS) -MT testAbs-testAbs.o -MD -MP -MF $(DEPDIR)/testAbs-testAbs.Tpo -c -o testAbs-testAbs.o `test -f 'testAbs.c' || echo '$(srcdir)/'`testAbs.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testAbs-testAbs.Tpo $(DEPDIR)/testAbs-testAbs.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testAbs.c' object='testAbs-testAbs.o' libtool=no @AMDEPBACKSLASH@ +testDoubleAbs-testDoubleAbs.o: testDoubleAbs.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testDoubleAbs_CFLAGS) $(CFLAGS) -MT testDoubleAbs-testDoubleAbs.o -MD -MP -MF $(DEPDIR)/testDoubleAbs-testDoubleAbs.Tpo -c -o testDoubleAbs-testDoubleAbs.o `test -f 'testDoubleAbs.c' || echo '$(srcdir)/'`testDoubleAbs.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testDoubleAbs-testDoubleAbs.Tpo $(DEPDIR)/testDoubleAbs-testDoubleAbs.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testDoubleAbs.c' object='testDoubleAbs-testDoubleAbs.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) $(testDoubleAbs_CFLAGS) $(CFLAGS) -c -o testDoubleAbs-testDoubleAbs.o `test -f 'testDoubleAbs.c' || echo '$(srcdir)/'`testDoubleAbs.c + +testDoubleAbs-testDoubleAbs.obj: testDoubleAbs.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testDoubleAbs_CFLAGS) $(CFLAGS) -MT testDoubleAbs-testDoubleAbs.obj -MD -MP -MF $(DEPDIR)/testDoubleAbs-testDoubleAbs.Tpo -c -o testDoubleAbs-testDoubleAbs.obj `if test -f 'testDoubleAbs.c'; then $(CYGPATH_W) 'testDoubleAbs.c'; else $(CYGPATH_W) '$(srcdir)/testDoubleAbs.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testDoubleAbs-testDoubleAbs.Tpo $(DEPDIR)/testDoubleAbs-testDoubleAbs.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testDoubleAbs.c' object='testDoubleAbs-testDoubleAbs.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) $(testDoubleAbs_CFLAGS) $(CFLAGS) -c -o testDoubleAbs-testDoubleAbs.obj `if test -f 'testDoubleAbs.c'; then $(CYGPATH_W) 'testDoubleAbs.c'; else $(CYGPATH_W) '$(srcdir)/testDoubleAbs.c'; fi` + +testFloatAbs-testFloatAbs.o: testFloatAbs.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testFloatAbs_CFLAGS) $(CFLAGS) -MT testFloatAbs-testFloatAbs.o -MD -MP -MF $(DEPDIR)/testFloatAbs-testFloatAbs.Tpo -c -o testFloatAbs-testFloatAbs.o `test -f 'testFloatAbs.c' || echo '$(srcdir)/'`testFloatAbs.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testFloatAbs-testFloatAbs.Tpo $(DEPDIR)/testFloatAbs-testFloatAbs.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testFloatAbs.c' object='testFloatAbs-testFloatAbs.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) $(testAbs_CFLAGS) $(CFLAGS) -c -o testAbs-testAbs.o `test -f 'testAbs.c' || echo '$(srcdir)/'`testAbs.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testFloatAbs_CFLAGS) $(CFLAGS) -c -o testFloatAbs-testFloatAbs.o `test -f 'testFloatAbs.c' || echo '$(srcdir)/'`testFloatAbs.c -testAbs-testAbs.obj: testAbs.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testAbs_CFLAGS) $(CFLAGS) -MT testAbs-testAbs.obj -MD -MP -MF $(DEPDIR)/testAbs-testAbs.Tpo -c -o testAbs-testAbs.obj `if test -f 'testAbs.c'; then $(CYGPATH_W) 'testAbs.c'; else $(CYGPATH_W) '$(srcdir)/testAbs.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testAbs-testAbs.Tpo $(DEPDIR)/testAbs-testAbs.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testAbs.c' object='testAbs-testAbs.obj' libtool=no @AMDEPBACKSLASH@ +testFloatAbs-testFloatAbs.obj: testFloatAbs.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testFloatAbs_CFLAGS) $(CFLAGS) -MT testFloatAbs-testFloatAbs.obj -MD -MP -MF $(DEPDIR)/testFloatAbs-testFloatAbs.Tpo -c -o testFloatAbs-testFloatAbs.obj `if test -f 'testFloatAbs.c'; then $(CYGPATH_W) 'testFloatAbs.c'; else $(CYGPATH_W) '$(srcdir)/testFloatAbs.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testFloatAbs-testFloatAbs.Tpo $(DEPDIR)/testFloatAbs-testFloatAbs.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testFloatAbs.c' object='testFloatAbs-testFloatAbs.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) $(testAbs_CFLAGS) $(CFLAGS) -c -o testAbs-testAbs.obj `if test -f 'testAbs.c'; then $(CYGPATH_W) 'testAbs.c'; else $(CYGPATH_W) '$(srcdir)/testAbs.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testFloatAbs_CFLAGS) $(CFLAGS) -c -o testFloatAbs-testFloatAbs.obj `if test -f 'testFloatAbs.c'; then $(CYGPATH_W) 'testFloatAbs.c'; else $(CYGPATH_W) '$(srcdir)/testFloatAbs.c'; fi` mostlyclean-libtool: -rm -f *.lo diff --git a/src/auxiliaryFunctions/abs/testAbs.c b/src/auxiliaryFunctions/abs/testAbs.c deleted file mode 100644 index c7c27faa..00000000 --- a/src/auxiliaryFunctions/abs/testAbs.c +++ /dev/null @@ -1,154 +0,0 @@ -/* -** -*- C -*- -** -** testAbs.c -** Made by Bruno JOFRET <bruno.jofret@inria.fr> -** -** Started on Wed Feb 14 15:50:15 2007 jofret -** Last update Mon Oct 22 15:27:49 2007 bruno -** -** Copyright INRIA 2007 -*/ - -#include "testAbs.h" - -int sabssTest() { - float value1 = -123456.789; - float value2 = 987654.321; - printf(">> Floats \n"); - assert(sabss(value1) == -value1); - assert(sabss(value2) == value2); - assert(sabss(0) == 0); - assert(sabss(-1) == 1); - assert(sabss(1) == 1); - return 0; -} - -int dabssTest() { - double value1 = -123456.789; - double value2 = 987654.321; - printf(">> Doubles \n"); - assert(dabss(value1) == -value1); - assert(dabss(value2) == value2); - assert(dabss(0) == 0); - assert(dabss(-1) == 1); - assert(dabss(1) == 1); - return 0; -} - -int cabssTest() { - floatComplex value1 = FloatComplex(4,3); - printf(">> Float Complex \n"); - assert(cabss(value1) == 5); - return 0; -} - -int zabssTest() { - doubleComplex value1 = DoubleComplex(4,3); - printf(">> Double Complex \n"); - assert(zabss(value1) == 5); - return 0; -} - -int sabsaTest() { - float value1 = -123456.789; - float value2 = 987654.321; - float value3 = 0; - float in[3]; - float out[3]; - - in[0] = value1; - in[1] = value2; - in[2] = value3; - - printf(">> Floats Array\n"); - sabsa(in, 3, out); - assert(out[0] == -value1); - assert(out[1] == value2); - assert(out[2] == value3); - assert(out[2] == 0); - return 0; -} - -int dabsaTest() { - double value1 = -123456.789; - double value2 = 987654.321; - double value3 = 0; - double in[3]; - double out[3]; - - in[0] = value1; - in[1] = value2; - in[2] = value3; - - printf(">> Doubles Array\n"); - dabsa(in, 3, out); - assert(out[0] == -value1); - assert(out[1] == value2); - assert(out[2] == value3); - assert(out[2] == 0); - return 0; -} - -int cabsaTest() { - floatComplex in[4]; - float out[4]; - - in[0] = FloatComplex(4,3); - in[1] = FloatComplex(-4,3); - in[2] = FloatComplex(4,-3); - in[3] = FloatComplex(-4,-3); - - printf(">> Float Complex Array\n"); - cabsa(in, 4, out); - assert(out[0] == 5); - assert(out[1] == 5); - assert(out[2] == 5); - assert(out[3] == 5); - return 0; -} - -int zabsaTest() { - doubleComplex in[4]; - double out[4]; - - in[0] = DoubleComplex(4,3); - in[1] = DoubleComplex(-4,3); - in[2] = DoubleComplex(4,-3); - in[3] = DoubleComplex(-4,-3); - - printf(">> Double Complex Array\n"); - zabsa(in, 4, out); - assert(out[0] == 5); - assert(out[1] == 5); - assert(out[2] == 5); - assert(out[3] == 5); - return 0; -} - -int testAbs() { - int sabssStatus, dabssStatus = 0; - int cabssStatus, zabssStatus = 0; - int sabsaStatus, dabsaStatus = 0; - int cabsaStatus, zabsaStatus = 0; - - printf(">>>> Abs Tests\n"); - sabssStatus = sabssTest(); - dabssStatus = dabssTest(); - cabssStatus = cabssTest(); - zabssStatus = zabssTest(); - sabsaStatus = sabsaTest(); - dabsaStatus = dabsaTest(); - cabsaStatus = cabsaTest(); - zabsaStatus = zabsaTest(); - - return (sabssStatus + dabssStatus + - cabssStatus + zabssStatus+ - sabsaStatus + dabsaStatus + - cabsaStatus + zabsaStatus); -} - -int main(void) { - assert(testAbs() == 0); - return 0; -} diff --git a/src/auxiliaryFunctions/abs/testDoubleAbs.c b/src/auxiliaryFunctions/abs/testDoubleAbs.c new file mode 100644 index 00000000..c096692e --- /dev/null +++ b/src/auxiliaryFunctions/abs/testDoubleAbs.c @@ -0,0 +1,93 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include "testAbs.h" + +int dabssTest() { + double value1 = -123456.789; + double value2 = 987654.321; + printf(">> Doubles \n"); + assert(dabss(value1) == -value1); + assert(dabss(value2) == value2); + assert(dabss(0) == 0); + assert(dabss(-1) == 1); + assert(dabss(1) == 1); + return 0; +} + +int zabssTest() { + doubleComplex value1 = DoubleComplex(4,3); + printf(">> Double Complex \n"); + assert(zabss(value1) == 5); + return 0; +} + +int dabsaTest() { + double value1 = -123456.789; + double value2 = 987654.321; + double value3 = 0; + double in[3]; + double out[3]; + + in[0] = value1; + in[1] = value2; + in[2] = value3; + + printf(">> Doubles Array\n"); + dabsa(in, 3, out); + assert(out[0] == -value1); + assert(out[1] == value2); + assert(out[2] == value3); + assert(out[2] == 0); + return 0; +} + +int zabsaTest() { + doubleComplex in[4]; + double out[4]; + + in[0] = DoubleComplex(4,3); + in[1] = DoubleComplex(-4,3); + in[2] = DoubleComplex(4,-3); + in[3] = DoubleComplex(-4,-3); + + printf(">> Double Complex Array\n"); + zabsa(in, 4, out); + assert(out[0] == 5); + assert(out[1] == 5); + assert(out[2] == 5); + assert(out[3] == 5); + return 0; +} + +int testAbs() { + int dabssStatus = 0; + int zabssStatus = 0; + int dabsaStatus = 0; + int zabsaStatus = 0; + + printf(">>>> Abs Tests\n"); + dabssStatus = dabssTest(); + zabssStatus = zabssTest(); + dabsaStatus = dabsaTest(); + zabsaStatus = zabsaTest(); + + return (dabssStatus + + zabssStatus+ + dabsaStatus + + zabsaStatus); +} + +int main(void) { + assert(testAbs() == 0); + return 0; +} diff --git a/src/auxiliaryFunctions/abs/testFloatAbs.c b/src/auxiliaryFunctions/abs/testFloatAbs.c new file mode 100644 index 00000000..93bbba63 --- /dev/null +++ b/src/auxiliaryFunctions/abs/testFloatAbs.c @@ -0,0 +1,93 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include "testAbs.h" + +int sabssTest() { + float value1 = -123456.789f; + float value2 = 987654.321f; + printf(">> Floats \n"); + assert(sabss(value1) == -value1); + assert(sabss(value2) == value2); + assert(sabss(0) == 0); + assert(sabss(-1) == 1); + assert(sabss(1) == 1); + return 0; +} + +int cabssTest() { + floatComplex value1 = FloatComplex(4.0f,3.0f); + printf(">> Float Complex \n"); + assert(cabss(value1) == 5.0f); + return 0; +} + +int sabsaTest() { + float value1 = -123456.789f; + float value2 = 987654.321f; + float value3 = 0.0f; + float in[3]; + float out[3]; + + in[0] = value1; + in[1] = value2; + in[2] = value3; + + printf(">> Floats Array\n"); + sabsa(in, 3, out); + assert(out[0] == -value1); + assert(out[1] == value2); + assert(out[2] == value3); + assert(out[2] == 0.0f); + return 0; +} + +int cabsaTest() { + floatComplex in[4]; + float out[4]; + + in[0] = FloatComplex(4.0f,3.0f); + in[1] = FloatComplex(-4.0f,3.0f); + in[2] = FloatComplex(4.0f,-3.0f); + in[3] = FloatComplex(-4.0f,-3.0f); + + printf(">> Float Complex Array\n"); + cabsa(in, 4, out); + assert(out[0] == 5.0f); + assert(out[1] == 5.0f); + assert(out[2] == 5.0f); + assert(out[3] == 5.0f); + return 0; +} + +int testAbs() { + int sabssStatus = 0; + int cabssStatus = 0; + int sabsaStatus = 0; + int cabsaStatus = 0; + + printf(">>>> Float Abs Tests\n"); + sabssStatus = sabssTest(); + cabssStatus = cabssTest(); + sabsaStatus = sabsaTest(); + cabsaStatus = cabsaTest(); + + return (sabssStatus + + cabssStatus + + sabsaStatus + + cabsaStatus); +} + +int main(void) { + assert(testAbs() == 0); + return 0; +} |