summaryrefslogtreecommitdiff
path: root/src/auxiliaryFunctions/pythag/testPythag.c
diff options
context:
space:
mode:
authorjofret2007-04-27 06:25:56 +0000
committerjofret2007-04-27 06:25:56 +0000
commitdebaf6d3cd5a17c0a88505c862c68a39b96aafe5 (patch)
treeb9d4055991db2f50912594c03fd37bddfcbb1cce /src/auxiliaryFunctions/pythag/testPythag.c
parent606f8456ba10ac1a785ed18e84300854ba3bf732 (diff)
downloadscilab2c-debaf6d3cd5a17c0a88505c862c68a39b96aafe5.tar.gz
scilab2c-debaf6d3cd5a17c0a88505c862c68a39b96aafe5.tar.bz2
scilab2c-debaf6d3cd5a17c0a88505c862c68a39b96aafe5.zip
Pythag function implementation
Diffstat (limited to 'src/auxiliaryFunctions/pythag/testPythag.c')
-rw-r--r--src/auxiliaryFunctions/pythag/testPythag.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/auxiliaryFunctions/pythag/testPythag.c b/src/auxiliaryFunctions/pythag/testPythag.c
new file mode 100644
index 00000000..2291823f
--- /dev/null
+++ b/src/auxiliaryFunctions/pythag/testPythag.c
@@ -0,0 +1,50 @@
+/*
+** -*- C -*-
+**
+** testPythag.c
+** Made by Bruno JOFRET <bruno.jofret@inria.fr>
+**
+** Started on Wed Feb 14 15:50:15 2007 jofret
+** Last update Tue Apr 24 11:35:22 2007 jofret
+**
+** Copyright INRIA 2007
+*/
+
+#include "testPythag.h"
+
+int spythagsTest() {
+ printf(">> Floats \n");
+ float value1 = -3;
+ float value2 = 4;
+ assert(spythags(value1, value2) == 5);
+ assert(spythags(0, 0) == 0);
+ assert(spythags(-3, 0) == 3);
+ assert(spythags(3, 0) == 3);
+ return 0;
+}
+
+int dpythagsTest() {
+ printf(">> Doubles \n");
+ double value1 = -3;
+ double value2 = 4;
+ assert(dpythags(value1, value2) == 5);
+ assert(dpythags(0, 0) == 0);
+ assert(dpythags(-3, 0) == 3);
+ assert(dpythags(3, 0) == 3);
+ return 0;
+}
+
+int testPythag() {
+ int spythagsStatus, dpythagsStatus = 0;
+
+ printf(">>>> Pythag Tests\n");
+ spythagsStatus = spythagsTest();
+ dpythagsStatus = dpythagsTest();
+
+ return (spythagsStatus + dpythagsStatus);
+}
+
+int main(void) {
+ assert(testPythag() == 0);
+ return 0;
+}