Salome HOME
MEDMEM suppression
[modules/med.git] / src / MEDMEMBinTest / test_MEDMEM_ModulusArray.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #include "MEDMEM_ModulusArray.hxx"
23
24 using namespace std;
25 using namespace MEDMEM;
26
27 int main (int argc, char ** argv) {
28   using namespace std ;
29
30   int array[5]={0,1,2,1,4} ;
31   MEDMODULUSARRAY modulusArray(5,array);
32
33   cout<<"ModuloArray :"<<endl;
34   for(int i=-10;i<15;i++)
35     cout <<"  - A["<<i<<"]="<<modulusArray[i]<<endl;
36   cout <<endl;
37
38   // test compare
39   int ret ;
40
41   int array2[5]={1,4,0,1,2} ;
42   MEDMODULUSARRAY modulusArray2(5,array2) ;
43   cout<<"Same arrays, same order ... ";
44   if ((ret=modulusArray2.compare(modulusArray))!=1)
45     cout << "Error : two arrays must be identical !"<<ret<<endl;
46   else
47     cout << "OK" <<endl;
48
49   int array3[5]={1,2,1,0,4} ;
50   MEDMODULUSARRAY modulusArray3(5,array3) ;
51   cout<<"Same arrays, reverse order ... ";
52   if ((ret=modulusArray3.compare(modulusArray))!=-1)
53     cout << "Error : two arrays are in reverse order !"<<ret<<endl;
54   else
55     cout << "OK" <<endl;
56
57   int array4[6]={1,2,1,0} ;
58   MEDMODULUSARRAY modulusArray4(4,array4) ;
59   cout<<"Different arrays size ... ";
60   if ((ret=modulusArray4.compare(modulusArray))!=0)
61     cout << "Error : two arrays have different size !"<<ret<<endl;
62   else
63     cout << "OK" <<endl;
64   
65   int array5[5]={1,2,1,0,1} ;
66   MEDMODULUSARRAY modulusArray5(5,array5) ;
67   cout<<"Different array, same size ... ";
68   if ((ret=modulusArray5.compare(modulusArray))!=0)
69     cout << "Error : two arrays are not be identical !"<<ret<<endl;
70   else
71     cout << "OK" <<endl;
72  
73   // test small array :
74
75   // 1
76   int array6[1]={1} ;
77   MEDMODULUSARRAY modulusArray6(1,array6);
78
79   cout<<"ModuloArray 1 :"<<endl;
80   for(int i=-10;i<15;i++)
81     cout <<"  - A["<<i<<"]="<<modulusArray6[i]<<endl;
82   cout <<endl;
83
84   int array7[1]={1} ;
85   MEDMODULUSARRAY modulusArray7(1,array7);
86   cout<<"Same arrays, same order ... ";
87   if ((ret=modulusArray6.compare(modulusArray7))!=1)
88     cout << "Error : two arrays are identical !"<<ret<<endl;
89   else
90     cout << "OK" <<endl;
91   int array8[1]={2} ;
92   MEDMODULUSARRAY modulusArray8(1,array8);
93   cout<<"Different arrays ... ";
94   if ((ret=modulusArray6.compare(modulusArray8))!=0)
95     cout << "Error : two arrays are different !"<<ret<<endl;
96   else
97     cout << "OK" <<endl;
98
99   
100   // 2
101   int array60[2]={1,2} ;
102   MEDMODULUSARRAY modulusArray60(2,array60);
103
104   cout<<"ModuloArray 2 :"<<endl;
105   for(int i=-10;i<15;i++)
106     cout <<"  - A["<<i<<"]="<<modulusArray60[i]<<endl;
107   cout <<endl;
108
109   int array70[2]={1,2} ;
110   MEDMODULUSARRAY modulusArray70(2,array70);
111   cout<<"Same arrays, same order ... ";
112   if ((ret=modulusArray60.compare(modulusArray70))!=1)
113     cout << "Error : two arrays are identical !"<<ret<<endl;
114   else
115     cout << "OK" <<endl;
116   int array80[2]={2,2} ;
117   MEDMODULUSARRAY modulusArray80(2,array80);
118   cout<<"Different arrays ... ";
119   if ((ret=modulusArray60.compare(modulusArray80))!=0)
120     cout << "Error : two arrays are different !"<<ret<<endl;
121   else
122     cout << "OK" <<endl;
123   int array90[2]={2,1} ;
124   MEDMODULUSARRAY modulusArray90(2,array90);
125   cout<<"Same arrays, reverse order ... ";
126   if ((ret=modulusArray60.compare(modulusArray90))!=-1)
127     cout << "Error : two arrays are in reverse order !"<<ret<<endl;
128   else
129     cout << "OK" <<endl;
130
131   
132
133  
134
135   return 0 ;
136 }