summaryrefslogtreecommitdiff
path: root/src/auxiliaryFunctions/pythag/testPythag.c
blob: 2291823f3932fd14e317b31e5edc47f473b86403 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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;
}