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