]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/test_MEDMEM_ModulusArray.cxx
Salome HOME
update due to bugs PAL8113 and another I do not remember the number ;) .
[modules/med.git] / src / MEDMEM / test_MEDMEM_ModulusArray.cxx
1 #include "utilities.h"
2
3 #include "MEDMEM_ModulusArray.hxx"
4
5 using namespace std;
6 using namespace MEDMEM;
7
8 int main (int argc, char ** argv) {
9
10   using namespace std ;
11
12   int array[5]={0,1,2,1,4} ;
13   MEDMODULUSARRAY modulusArray(5,array);
14
15   cout<<"ModuloArray :"<<endl;
16   for(int i=-10;i<15;i++)
17     cout <<"  - A["<<i<<"]="<<modulusArray[i]<<endl;
18   cout <<endl;
19
20   // test compare
21   int ret ;
22
23   int array2[5]={1,4,0,1,2} ;
24   MEDMODULUSARRAY modulusArray2(5,array2) ;
25   cout<<"Same arrays, same order ... ";
26   if ((ret=modulusArray2.compare(modulusArray))!=1)
27     cout << "Error : two arrays must be identical !"<<ret<<endl;
28   else
29     cout << "OK" <<endl;
30
31   int array3[5]={1,2,1,0,4} ;
32   MEDMODULUSARRAY modulusArray3(5,array3) ;
33   cout<<"Same arrays, reverse order ... ";
34   if ((ret=modulusArray3.compare(modulusArray))!=-1)
35     cout << "Error : two arrays are in reverse order !"<<ret<<endl;
36   else
37     cout << "OK" <<endl;
38
39   int array4[6]={1,2,1,0} ;
40   MEDMODULUSARRAY modulusArray4(4,array4) ;
41   cout<<"Different arrays size ... ";
42   if ((ret=modulusArray4.compare(modulusArray))!=0)
43     cout << "Error : two arrays have different size !"<<ret<<endl;
44   else
45     cout << "OK" <<endl;
46   
47   int array5[5]={1,2,1,0,1} ;
48   MEDMODULUSARRAY modulusArray5(5,array5) ;
49   cout<<"Different array, same size ... ";
50   if ((ret=modulusArray5.compare(modulusArray))!=0)
51     cout << "Error : two arrays are not be identical !"<<ret<<endl;
52   else
53     cout << "OK" <<endl;
54  
55   // test small array :
56
57   // 1
58   int array6[1]={1} ;
59   MEDMODULUSARRAY modulusArray6(1,array6);
60
61   cout<<"ModuloArray 1 :"<<endl;
62   for(int i=-10;i<15;i++)
63     cout <<"  - A["<<i<<"]="<<modulusArray6[i]<<endl;
64   cout <<endl;
65
66   int array7[1]={1} ;
67   MEDMODULUSARRAY modulusArray7(1,array7);
68   cout<<"Same arrays, same order ... ";
69   if ((ret=modulusArray6.compare(modulusArray7))!=1)
70     cout << "Error : two arrays are identical !"<<ret<<endl;
71   else
72     cout << "OK" <<endl;
73   int array8[1]={2} ;
74   MEDMODULUSARRAY modulusArray8(1,array8);
75   cout<<"Different arrays ... ";
76   if ((ret=modulusArray6.compare(modulusArray8))!=0)
77     cout << "Error : two arrays are different !"<<ret<<endl;
78   else
79     cout << "OK" <<endl;
80
81   
82   // 2
83   int array60[2]={1,2} ;
84   MEDMODULUSARRAY modulusArray60(2,array60);
85
86   cout<<"ModuloArray 2 :"<<endl;
87   for(int i=-10;i<15;i++)
88     cout <<"  - A["<<i<<"]="<<modulusArray60[i]<<endl;
89   cout <<endl;
90
91   int array70[2]={1,2} ;
92   MEDMODULUSARRAY modulusArray70(2,array70);
93   cout<<"Same arrays, same order ... ";
94   if ((ret=modulusArray60.compare(modulusArray70))!=1)
95     cout << "Error : two arrays are identical !"<<ret<<endl;
96   else
97     cout << "OK" <<endl;
98   int array80[2]={2,2} ;
99   MEDMODULUSARRAY modulusArray80(2,array80);
100   cout<<"Different arrays ... ";
101   if ((ret=modulusArray60.compare(modulusArray80))!=0)
102     cout << "Error : two arrays are different !"<<ret<<endl;
103   else
104     cout << "OK" <<endl;
105   int array90[2]={2,1} ;
106   MEDMODULUSARRAY modulusArray90(2,array90);
107   cout<<"Same arrays, reverse order ... ";
108   if ((ret=modulusArray60.compare(modulusArray90))!=-1)
109     cout << "Error : two arrays are in reverse order !"<<ret<<endl;
110   else
111     cout << "OK" <<endl;
112
113   
114
115  
116
117   return 0 ;
118 }