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"
31 int main (int argc, char ** argv)
36 int array[5]={0,1,2,1,4} ;
37 MEDMODULUSARRAY modulusArray(5,array);
39 cout << " ModulusArray : " << endl;
40 cout << " _______________" << endl;
41 for(int i=-10;i<15;i++)
43 cout <<" - A[" << i <<"]="<<modulusArray[i]<<endl;
52 int array2[5]={1,4,0,1,2} ;
53 MEDMODULUSARRAY modulusArray2(5,array2) ;
55 cout << " Test compare : mêmes tableaux mêmes ordres ..." << endl;
59 ret=modulusArray2.compare(modulusArray);
61 catch ( const std::exception &e )
63 cout << "-----------------" << endl;
64 cout << " pb avec compare " << endl;
65 cout << "-----------------" << endl;
66 MESSAGE( "catched exception : " << e.what() ) ;
71 cout << "-----------------" << endl;
72 cout << " pb avec compare " << endl;
73 cout << "-----------------" << endl;
79 cout << "-----------------------------------------------------" << endl;
80 cout << " pb avec compare entre modulusArray et modulusArray2 " << endl;
81 cout << " Les deux tableaux sont identiques " << endl;
82 cout << "-----------------------------------------------------" << endl;
87 cout << " compare entre modulusArray et modulusArray2 : OK" << endl;
91 int array3[5]={1,2,1,0,4} ;
92 MEDMODULUSARRAY modulusArray3(5,array3) ;
94 cout << " Test compare : mêmes tableaux ordres inverses ..." << endl;
98 ret=modulusArray3.compare(modulusArray);
100 catch (const std::exception &e )
102 cout << "-----------------" << endl;
103 cout << " pb avec compare " << endl;
104 cout << "-----------------" << endl;
105 MESSAGE( "catched exception : " << e.what() ) ;
106 return EXIT_FAILURE ;
110 cout << "-----------------" << endl;
111 cout << " pb avec compare " << endl;
112 cout << "-----------------" << endl;
113 return EXIT_FAILURE ;
118 cout << "-----------------------------------------------------" << endl;
119 cout << " pb avec compare entre modulusArray et modulusArray3 " << endl;
120 cout << " Les deux tableaux sont inverses " << endl;
121 cout << "-----------------------------------------------------" << endl;
122 return EXIT_FAILURE ;
126 cout << " compare entre modulusArray et modulusArray3 : OK" << endl;
130 int array4[6]={1,2,1,0} ;
131 MEDMODULUSARRAY modulusArray4(4,array4) ;
133 cout << " Test compare : Tableaux de differentes tailles ... " << endl;
136 ret=modulusArray4.compare(modulusArray);
138 catch (const std::exception &e )
140 cout << "-----------------" << endl;
141 cout << " pb avec compare " << endl;
142 cout << "-----------------" << endl;
143 MESSAGE( "catched exception : " << e.what() ) ;
144 return EXIT_FAILURE ;
148 cout << "-----------------" << endl;
149 cout << " pb avec compare " << endl;
150 cout << "-----------------" << endl;
151 return EXIT_FAILURE ;
156 cout << "-----------------------------------------------------" << endl;
157 cout << " pb avec compare entre modulusArray et modulusArray4 " << endl;
158 cout << " Les deux n ont pas la meme taille " << endl;
159 cout << "-----------------------------------------------------" << endl;
160 return EXIT_FAILURE ;
164 cout << " compare entre modulusArray et modulusArray4 : OK" << endl;
168 int array5[5]={1,2,1,0,1} ;
169 MEDMODULUSARRAY modulusArray5(5,array5) ;
170 cout << " Test compare : tableaux differents de même taille ..." << endl;
173 ret=modulusArray5.compare(modulusArray);
175 catch (const std::exception &e )
177 cout << "-----------------" << endl;
178 cout << " pb avec compare " << endl;
179 cout << "-----------------" << endl;
180 MESSAGE( "catched exception : " << e.what() ) ;
181 return EXIT_FAILURE ;
185 cout << "-----------------" << endl;
186 cout << " pb avec compare " << endl;
187 cout << "-----------------" << endl;
188 return EXIT_FAILURE ;
193 cout << "-----------------------------------------------------" << endl;
194 cout << " pb avec compare entre modulusArray et modulusArray5 " << endl;
195 cout << " Les deux tableaux sont differents " << endl;
196 cout << "-----------------------------------------------------" << endl;
197 return EXIT_FAILURE ;
201 cout << " compare entre modulusArray et modulusArray5 : OK" << endl;
205 // test small array :
208 MEDMODULUSARRAY modulusArray6(1,array6);
210 cout << " ModulusArray 1 : " << endl;
211 cout << " __________________" << endl;
213 for(int i=-10;i<15;i++)
215 cout <<" - A[" << i <<"]="<<modulusArray6[i]<<endl;
220 MEDMODULUSARRAY modulusArray7(1,array7);
222 cout << " Test compare : mêmes tableaux mêmes ordres ..." << endl;
225 ret=modulusArray6.compare(modulusArray7);
227 catch ( const std::exception &e )
229 cout << "-----------------" << endl;
230 cout << " pb avec compare " << endl;
231 cout << "-----------------" << endl;
232 MESSAGE( "catched exception : " << e.what() ) ;
233 return EXIT_FAILURE ;
237 cout << "-----------------" << endl;
238 cout << " pb avec compare " << endl;
239 cout << "-----------------" << endl;
240 return EXIT_FAILURE ;
245 cout << "-----------------------------------------------------" << endl;
246 cout << " pb avec compare entre modulusArray6 et modulusArray7" << endl;
247 cout << " Les deux tableaux sont identiques " << endl;
248 cout << "-----------------------------------------------------" << endl;
249 return EXIT_FAILURE ;
253 cout << " compare entre modulusArray6 et modulusArray7 : OK" << endl ;
258 MEDMODULUSARRAY modulusArray8(1,array8);
260 cout << " Test compare : tableaux differents "<< endl;
263 ret=modulusArray6.compare(modulusArray8);
265 catch ( const std::exception &e )
267 cout << "-----------------" << endl;
268 cout << " pb avec compare " << endl;
269 cout << "-----------------" << endl;
270 MESSAGE( "catched exception : " << e.what() ) ;
271 return EXIT_FAILURE ;
275 cout << "-----------------" << endl;
276 cout << " pb avec compare " << endl;
277 cout << "-----------------" << endl;
278 return EXIT_FAILURE ;
283 cout << "-----------------------------------------------------" << endl;
284 cout << " pb avec compare entre modulusArray6 et modulusArray8" << endl;
285 cout << " Les deux tableaux sont differents" << endl;
286 cout << "-----------------------------------------------------" << endl;
287 return EXIT_FAILURE ;
291 cout << " compare entre modulusArray6 et modulusArray8 : OK" << endl;
297 int array60[2]={1,2} ;
298 MEDMODULUSARRAY modulusArray60(2,array60);
301 cout << " ModulusArray 2 : " << endl;
302 cout << " __________________" << endl;
304 for(int i=-10;i<15;i++)
306 cout <<" - A[" << i <<"]="<<modulusArray60[i]<<endl;
310 int array70[2]={1,2} ;
311 MEDMODULUSARRAY modulusArray70(2,array70);
312 cout << " Test compare : mêmes tableaux mêmes ordres ..." << endl;
316 ret=modulusArray60.compare(modulusArray70);
318 catch ( const std::exception &e )
320 cout << "-----------------" << endl;
321 cout << " pb avec compare " << endl;
322 cout << "-----------------" << endl;
323 MESSAGE( "catched exception : " << e.what() ) ;
324 return EXIT_FAILURE ;
328 cout << "-----------------" << endl;
329 cout << " pb avec compare " << endl;
330 cout << "-----------------" << endl;
331 return EXIT_FAILURE ;
336 cout << "--------------------------------------------------------" << endl;
337 cout << " pb avec compare entre modulusArray60 et modulusArray70 " << endl;
338 cout << " Les deux tableaux sont identiques " << endl;
339 cout << "--------------------------------------------------------" << endl;
340 return EXIT_FAILURE ;
344 cout << " compare entre modulusArray60 et modulusArray70 : OK" << endl;
348 int array80[2]={2,2} ;
349 MEDMODULUSARRAY modulusArray80(2,array80);
351 cout << " Test compare : tableaux differents ..." << endl;
355 ret=modulusArray60.compare(modulusArray80);
357 catch ( const std::exception &e )
359 cout << "-----------------" << endl;
360 cout << " pb avec compare " << endl;
361 cout << "-----------------" << endl;
362 MESSAGE( "catched exception : " << e.what() ) ;
363 return EXIT_FAILURE ;
367 cout << "-----------------" << endl;
368 cout << " pb avec compare " << endl;
369 cout << "-----------------" << endl;
370 return EXIT_FAILURE ;
375 cout << "--------------------------------------------------------" << endl;
376 cout << " pb avec compare entre modulusArray60 et modulusArray80 " << endl;
377 cout << " Les deux tableaux sont differents " << endl;
378 cout << "--------------------------------------------------------" << endl;
379 return EXIT_FAILURE ;
383 cout << " compare entre modulusArray60 et modulusArray80 : OK" << endl;
387 int array90[2]={2,1} ;
388 MEDMODULUSARRAY modulusArray90(2,array90);
389 cout << " Test compare : tableaux differents ordres inverses ..." << endl;
392 ret=modulusArray60.compare(modulusArray90);
394 catch ( const std::exception &e )
396 cout << "-----------------" << endl;
397 cout << " pb avec compare " << endl;
398 cout << "-----------------" << endl;
399 MESSAGE( "catched exception : " << e.what() ) ;
400 return EXIT_FAILURE ;
404 cout << "-----------------" << endl;
405 cout << " pb avec compare " << endl;
406 cout << "-----------------" << endl;
407 return EXIT_FAILURE ;
412 cout << "--------------------------------------------------------" << endl;
413 cout << " pb avec compare entre modulusArray60 et modulusArray90 " << endl;
414 cout << " Les deux tableaux sont differents " << endl;
415 cout << "--------------------------------------------------------" << endl;
416 return EXIT_FAILURE ;
420 cout << " compare entre modulusArray60 et modulusArray90 : OK" << endl;
424 return EXIT_SUCCESS ;