summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/auxiliaryFunctions/isempty/testIsEmpty.c
blob: 011b5d2fdeb471f7b7e87ddbeba1146ed8f4b679 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 *  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 "testIsEmpty.h"

int sisemptyaTest() {
  int result = 0;
  float *empty;
  float full[5] = {1., 2., 3., 0., 0.};
  float out;
  
  empty = NULL;
  full[4]=0;
  
  printf(">> Float array\n");
  
  out=sisemptya(empty, 0);
  if (out == 0) {
    printf("ERROR1 ! : Test Failed (empty array)\n");
    result = ERROR;
  }
  assert (out == 1);
  
  
  out = sisemptya(full, 5);
  if ( out == 1) {
    printf("ERROR2 ! : Test Failed (non empty array)\n");
    result = ERROR;
  }
  assert(out == 0);

  return result;
}

int disemptyaTest() {
  int result = 0;
  double *empty;
  double full[5] = {1., 2., 3., 0., 0.};
  double out;
  
  empty = NULL;
  full[4]=0;
  
  
  printf(">> Double array\n");
  out=disemptya(empty, 0);
  if (out == 0) {
    printf("ERROR1 ! : Test Failed (empty array)\n");
    result = ERROR;
  }
  
  assert(out == 1);
  
  
  out=disemptya(full, 5);
  if (out == 1) {
    printf("ERROR2 ! : Test Failed (non empty array)\n");
    result = ERROR;
  }
  assert(out == 0);

  return result;
}

int cisemptyaTest() {
  int result = 0;
  floatComplex *empty;
  floatComplex full[5];
  float out;

  empty=NULL;
  
  full[0] = FloatComplex(0.,1.);
  full[1] = FloatComplex(0., 2.);
  full[2] = FloatComplex(0., 3.);
  full[3] = FloatComplex(0., 0.);
  full[4] = FloatComplex(0., 0.);

  printf(">> Float Complex array\n");
  
  out = cisemptya(empty, 0);
  if (out == 0) {
    printf("ERROR1 ! : Test Failed (empty array)\n");
    result = ERROR;
  }
  assert (out == 1);


  out = cisemptya(full, 5);
  if (out == 1) {
    printf("ERROR2 ! : Test Failed (non empty array)\n");
    result = ERROR;
  }
  assert(out == 0);


  return result;
}

int zisemptyaTest() {
  int result = 0;
  doubleComplex *empty;
  doubleComplex full[5];
  double out;

  empty=NULL;

  full[0] = DoubleComplex(0.,1.);
  full[1] = DoubleComplex(0., 2.);
  full[2] = DoubleComplex(0., 3.);
  full[3] = DoubleComplex(0., 0.);
  full[4] = DoubleComplex(0., 0.);;

  printf(">> Double Complex array\n");
  
  out = zisemptya(empty, 0);
  if (out == 0) {
    printf("ERROR1 ! : Test Failed (empty array)\n");
    result = ERROR;
  }
  assert (out == 1);

  out = zisemptya(full, 5);
  if (out == 1) {
    printf("ERROR2 ! : Test Failed (non empty array)\n");
    result = ERROR;
  }
  assert(out == 0);


  return result;
}


int testIsEmpty() {
  int sisemptyaTestStatus, disemptyaTestStatus = 0;
  int cisemptyaTestStatus, zisemptyaTestStatus = 0;
  printf("\n>>>> IsEmpty Tests\n");
  sisemptyaTestStatus = sisemptyaTest();
  disemptyaTestStatus = disemptyaTest();
  cisemptyaTestStatus = cisemptyaTest();
  zisemptyaTestStatus = zisemptyaTest();
  return (sisemptyaTestStatus + disemptyaTestStatus +
	  cisemptyaTestStatus + zisemptyaTestStatus);
}

int main(void) {
  assert(testIsEmpty() == 0);
  return 0;
}