1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : testUModulusArray.cxx
28 #include "utilities.h"
29 #include "MEDMEM_ModulusArray.hxx"
30 using namespace MEDMEM;
32 int main (int argc, char ** argv)
37 int array[5]={0,1,2,1,4} ;
38 MEDMODULUSARRAY modulusArray(5,array);
40 cout << " ModulusArray : " << endl;
41 cout << " _______________" << endl;
42 for(int i=-10;i<15;i++)
44 cout <<" - A[" << i <<"]="<<modulusArray[i]<<endl;
53 int array2[5]={1,4,0,1,2} ;
54 MEDMODULUSARRAY modulusArray2(5,array2) ;
56 cout << " Test compare : mêmes tableaux mêmes ordres ..." << endl;
60 ret=modulusArray2.compare(modulusArray);
62 catch ( const std::exception &e )
64 cout << "-----------------" << endl;
65 cout << " pb avec compare " << endl;
66 cout << "-----------------" << endl;
67 MESSAGE( "catched exception : " << e.what() ) ;
72 cout << "-----------------" << endl;
73 cout << " pb avec compare " << endl;
74 cout << "-----------------" << endl;
80 cout << "-----------------------------------------------------" << endl;
81 cout << " pb avec compare entre modulusArray et modulusArray2 " << endl;
82 cout << " Les deux tableaux sont identiques " << endl;
83 cout << "-----------------------------------------------------" << endl;
88 cout << " compare entre modulusArray et modulusArray2 : OK" << endl;
92 int array3[5]={1,2,1,0,4} ;
93 MEDMODULUSARRAY modulusArray3(5,array3) ;
95 cout << " Test compare : mêmes tableaux ordres inverses ..." << endl;
99 ret=modulusArray3.compare(modulusArray);
101 catch (const std::exception &e )
103 cout << "-----------------" << endl;
104 cout << " pb avec compare " << endl;
105 cout << "-----------------" << endl;
106 MESSAGE( "catched exception : " << e.what() ) ;
107 return EXIT_FAILURE ;
111 cout << "-----------------" << endl;
112 cout << " pb avec compare " << endl;
113 cout << "-----------------" << endl;
114 return EXIT_FAILURE ;
119 cout << "-----------------------------------------------------" << endl;
120 cout << " pb avec compare entre modulusArray et modulusArray3 " << endl;
121 cout << " Les deux tableaux sont inverses " << endl;
122 cout << "-----------------------------------------------------" << endl;
123 return EXIT_FAILURE ;
127 cout << " compare entre modulusArray et modulusArray3 : OK" << endl;
131 int array4[6]={1,2,1,0} ;
132 MEDMODULUSARRAY modulusArray4(4,array4) ;
134 cout << " Test compare : Tableaux de differentes tailles ... " << endl;
137 ret=modulusArray4.compare(modulusArray);
139 catch (const std::exception &e )
141 cout << "-----------------" << endl;
142 cout << " pb avec compare " << endl;
143 cout << "-----------------" << endl;
144 MESSAGE( "catched exception : " << e.what() ) ;
145 return EXIT_FAILURE ;
149 cout << "-----------------" << endl;
150 cout << " pb avec compare " << endl;
151 cout << "-----------------" << endl;
152 return EXIT_FAILURE ;
157 cout << "-----------------------------------------------------" << endl;
158 cout << " pb avec compare entre modulusArray et modulusArray4 " << endl;
159 cout << " Les deux n ont pas la meme taille " << endl;
160 cout << "-----------------------------------------------------" << endl;
161 return EXIT_FAILURE ;
165 cout << " compare entre modulusArray et modulusArray4 : OK" << endl;
169 int array5[5]={1,2,1,0,1} ;
170 MEDMODULUSARRAY modulusArray5(5,array5) ;
171 cout << " Test compare : tableaux differents de même taille ..." << endl;
174 ret=modulusArray5.compare(modulusArray);
176 catch (const std::exception &e )
178 cout << "-----------------" << endl;
179 cout << " pb avec compare " << endl;
180 cout << "-----------------" << endl;
181 MESSAGE( "catched exception : " << e.what() ) ;
182 return EXIT_FAILURE ;
186 cout << "-----------------" << endl;
187 cout << " pb avec compare " << endl;
188 cout << "-----------------" << endl;
189 return EXIT_FAILURE ;
194 cout << "-----------------------------------------------------" << endl;
195 cout << " pb avec compare entre modulusArray et modulusArray5 " << endl;
196 cout << " Les deux tableaux sont differents " << endl;
197 cout << "-----------------------------------------------------" << endl;
198 return EXIT_FAILURE ;
202 cout << " compare entre modulusArray et modulusArray5 : OK" << endl;
206 // test small array :
209 MEDMODULUSARRAY modulusArray6(1,array6);
211 cout << " ModulusArray 1 : " << endl;
212 cout << " __________________" << endl;
214 for(int i=-10;i<15;i++)
216 cout <<" - A[" << i <<"]="<<modulusArray6[i]<<endl;
221 MEDMODULUSARRAY modulusArray7(1,array7);
223 cout << " Test compare : mêmes tableaux mêmes ordres ..." << endl;
226 ret=modulusArray6.compare(modulusArray7);
228 catch ( const std::exception &e )
230 cout << "-----------------" << endl;
231 cout << " pb avec compare " << endl;
232 cout << "-----------------" << endl;
233 MESSAGE( "catched exception : " << e.what() ) ;
234 return EXIT_FAILURE ;
238 cout << "-----------------" << endl;
239 cout << " pb avec compare " << endl;
240 cout << "-----------------" << endl;
241 return EXIT_FAILURE ;
246 cout << "-----------------------------------------------------" << endl;
247 cout << " pb avec compare entre modulusArray6 et modulusArray7" << endl;
248 cout << " Les deux tableaux sont identiques " << endl;
249 cout << "-----------------------------------------------------" << endl;
250 return EXIT_FAILURE ;
254 cout << " compare entre modulusArray6 et modulusArray7 : OK" << endl ;
259 MEDMODULUSARRAY modulusArray8(1,array8);
261 cout << " Test compare : tableaux differents "<< endl;
264 ret=modulusArray6.compare(modulusArray8);
266 catch ( const std::exception &e )
268 cout << "-----------------" << endl;
269 cout << " pb avec compare " << endl;
270 cout << "-----------------" << endl;
271 MESSAGE( "catched exception : " << e.what() ) ;
272 return EXIT_FAILURE ;
276 cout << "-----------------" << endl;
277 cout << " pb avec compare " << endl;
278 cout << "-----------------" << endl;
279 return EXIT_FAILURE ;
284 cout << "-----------------------------------------------------" << endl;
285 cout << " pb avec compare entre modulusArray6 et modulusArray8" << endl;
286 cout << " Les deux tableaux sont differents" << endl;
287 cout << "-----------------------------------------------------" << endl;
288 return EXIT_FAILURE ;
292 cout << " compare entre modulusArray6 et modulusArray8 : OK" << endl;
298 int array60[2]={1,2} ;
299 MEDMODULUSARRAY modulusArray60(2,array60);
302 cout << " ModulusArray 2 : " << endl;
303 cout << " __________________" << endl;
305 for(int i=-10;i<15;i++)
307 cout <<" - A[" << i <<"]="<<modulusArray60[i]<<endl;
311 int array70[2]={1,2} ;
312 MEDMODULUSARRAY modulusArray70(2,array70);
313 cout << " Test compare : mêmes tableaux mêmes ordres ..." << endl;
317 ret=modulusArray60.compare(modulusArray70);
319 catch ( const std::exception &e )
321 cout << "-----------------" << endl;
322 cout << " pb avec compare " << endl;
323 cout << "-----------------" << endl;
324 MESSAGE( "catched exception : " << e.what() ) ;
325 return EXIT_FAILURE ;
329 cout << "-----------------" << endl;
330 cout << " pb avec compare " << endl;
331 cout << "-----------------" << endl;
332 return EXIT_FAILURE ;
337 cout << "--------------------------------------------------------" << endl;
338 cout << " pb avec compare entre modulusArray60 et modulusArray70 " << endl;
339 cout << " Les deux tableaux sont identiques " << endl;
340 cout << "--------------------------------------------------------" << endl;
341 return EXIT_FAILURE ;
345 cout << " compare entre modulusArray60 et modulusArray70 : OK" << endl;
349 int array80[2]={2,2} ;
350 MEDMODULUSARRAY modulusArray80(2,array80);
352 cout << " Test compare : tableaux differents ..." << endl;
356 ret=modulusArray60.compare(modulusArray80);
358 catch ( const std::exception &e )
360 cout << "-----------------" << endl;
361 cout << " pb avec compare " << endl;
362 cout << "-----------------" << endl;
363 MESSAGE( "catched exception : " << e.what() ) ;
364 return EXIT_FAILURE ;
368 cout << "-----------------" << endl;
369 cout << " pb avec compare " << endl;
370 cout << "-----------------" << endl;
371 return EXIT_FAILURE ;
376 cout << "--------------------------------------------------------" << endl;
377 cout << " pb avec compare entre modulusArray60 et modulusArray80 " << endl;
378 cout << " Les deux tableaux sont differents " << endl;
379 cout << "--------------------------------------------------------" << endl;
380 return EXIT_FAILURE ;
384 cout << " compare entre modulusArray60 et modulusArray80 : OK" << endl;
388 int array90[2]={2,1} ;
389 MEDMODULUSARRAY modulusArray90(2,array90);
390 cout << " Test compare : tableaux differents ordres inverses ..." << endl;
393 ret=modulusArray60.compare(modulusArray90);
395 catch ( const std::exception &e )
397 cout << "-----------------" << endl;
398 cout << " pb avec compare " << endl;
399 cout << "-----------------" << endl;
400 MESSAGE( "catched exception : " << e.what() ) ;
401 return EXIT_FAILURE ;
405 cout << "-----------------" << endl;
406 cout << " pb avec compare " << endl;
407 cout << "-----------------" << endl;
408 return EXIT_FAILURE ;
413 cout << "--------------------------------------------------------" << endl;
414 cout << " pb avec compare entre modulusArray60 et modulusArray90 " << endl;
415 cout << " Les deux tableaux sont differents " << endl;
416 cout << "--------------------------------------------------------" << endl;
417 return EXIT_FAILURE ;
421 cout << " compare entre modulusArray60 et modulusArray90 : OK" << endl;
425 return EXIT_SUCCESS ;