]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/test_MEDMEM_ModulusArray.cxx
Salome HOME
sources v1.2
[modules/med.git] / src / MEDMEM / test_MEDMEM_ModulusArray.cxx
1 //  MED MEDMEM : MED files in memory
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : test_MEDMEM_ModulusArray.cxx
25 //  Module : MED
26
27 using namespace std;
28 #include "utilities.h"
29
30 #include "MEDMEM_ModulusArray.hxx"
31
32 int main (int argc, char ** argv) {
33
34   using namespace std ;
35
36   int array[5]={0,1,2,1,4} ;
37   MEDMODULUSARRAY modulusArray(5,array);
38
39   cout<<"ModuloArray :"<<endl;
40   for(int i=-10;i<15;i++)
41     cout <<"  - A["<<i<<"]="<<modulusArray[i]<<endl;
42   cout <<endl;
43
44   // test compare
45   int ret ;
46
47   int array2[5]={1,4,0,1,2} ;
48   MEDMODULUSARRAY modulusArray2(5,array2) ;
49   cout<<"Same arrays, same order ... ";
50   if ((ret=modulusArray2.compare(modulusArray))!=1)
51     cout << "Error : two arrays must be identical !"<<ret<<endl;
52   else
53     cout << "OK" <<endl;
54
55   int array3[5]={1,2,1,0,4} ;
56   MEDMODULUSARRAY modulusArray3(5,array3) ;
57   cout<<"Same arrays, reverse order ... ";
58   if ((ret=modulusArray3.compare(modulusArray))!=-1)
59     cout << "Error : two arrays are in reverse order !"<<ret<<endl;
60   else
61     cout << "OK" <<endl;
62
63   int array4[6]={1,2,1,0} ;
64   MEDMODULUSARRAY modulusArray4(4,array4) ;
65   cout<<"Different arrays size ... ";
66   if ((ret=modulusArray4.compare(modulusArray))!=0)
67     cout << "Error : two arrays have different size !"<<ret<<endl;
68   else
69     cout << "OK" <<endl;
70   
71   int array5[5]={1,2,1,0,1} ;
72   MEDMODULUSARRAY modulusArray5(5,array5) ;
73   cout<<"Different array, same size ... ";
74   if ((ret=modulusArray5.compare(modulusArray))!=0)
75     cout << "Error : two arrays are not be identical !"<<ret<<endl;
76   else
77     cout << "OK" <<endl;
78  
79   // test small array :
80
81   // 1
82   int array6[1]={1} ;
83   MEDMODULUSARRAY modulusArray6(1,array6);
84
85   cout<<"ModuloArray 1 :"<<endl;
86   for(int i=-10;i<15;i++)
87     cout <<"  - A["<<i<<"]="<<modulusArray6[i]<<endl;
88   cout <<endl;
89
90   int array7[1]={1} ;
91   MEDMODULUSARRAY modulusArray7(1,array7);
92   cout<<"Same arrays, same order ... ";
93   if ((ret=modulusArray6.compare(modulusArray7))!=1)
94     cout << "Error : two arrays are identical !"<<ret<<endl;
95   else
96     cout << "OK" <<endl;
97   int array8[1]={2} ;
98   MEDMODULUSARRAY modulusArray8(1,array8);
99   cout<<"Different arrays ... ";
100   if ((ret=modulusArray6.compare(modulusArray8))!=0)
101     cout << "Error : two arrays are different !"<<ret<<endl;
102   else
103     cout << "OK" <<endl;
104
105   
106   // 2
107   int array60[2]={1,2} ;
108   MEDMODULUSARRAY modulusArray60(2,array60);
109
110   cout<<"ModuloArray 2 :"<<endl;
111   for(int i=-10;i<15;i++)
112     cout <<"  - A["<<i<<"]="<<modulusArray60[i]<<endl;
113   cout <<endl;
114
115   int array70[2]={1,2} ;
116   MEDMODULUSARRAY modulusArray70(2,array70);
117   cout<<"Same arrays, same order ... ";
118   if ((ret=modulusArray60.compare(modulusArray70))!=1)
119     cout << "Error : two arrays are identical !"<<ret<<endl;
120   else
121     cout << "OK" <<endl;
122   int array80[2]={2,2} ;
123   MEDMODULUSARRAY modulusArray80(2,array80);
124   cout<<"Different arrays ... ";
125   if ((ret=modulusArray60.compare(modulusArray80))!=0)
126     cout << "Error : two arrays are different !"<<ret<<endl;
127   else
128     cout << "OK" <<endl;
129   int array90[2]={2,1} ;
130   MEDMODULUSARRAY modulusArray90(2,array90);
131   cout<<"Same arrays, reverse order ... ";
132   if ((ret=modulusArray60.compare(modulusArray90))!=-1)
133     cout << "Error : two arrays are in reverse order !"<<ret<<endl;
134   else
135     cout << "OK" <<endl;
136
137   
138
139  
140
141   return 0 ;
142 }