Back to index

salome-med  6.5.0
test_MEDMEM_ModulusArray.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 #include "MEDMEM_ModulusArray.hxx"
00023 
00024 using namespace std;
00025 using namespace MEDMEM;
00026 
00027 int main (int argc, char ** argv) {
00028   using namespace std ;
00029 
00030   int array[5]={0,1,2,1,4} ;
00031   MEDMODULUSARRAY modulusArray(5,array);
00032 
00033   cout<<"ModuloArray :"<<endl;
00034   for(int i=-10;i<15;i++)
00035     cout <<"  - A["<<i<<"]="<<modulusArray[i]<<endl;
00036   cout <<endl;
00037 
00038   // test compare
00039   int ret ;
00040 
00041   int array2[5]={1,4,0,1,2} ;
00042   MEDMODULUSARRAY modulusArray2(5,array2) ;
00043   cout<<"Same arrays, same order ... ";
00044   if ((ret=modulusArray2.compare(modulusArray))!=1)
00045     cout << "Error : two arrays must be identical !"<<ret<<endl;
00046   else
00047     cout << "OK" <<endl;
00048 
00049   int array3[5]={1,2,1,0,4} ;
00050   MEDMODULUSARRAY modulusArray3(5,array3) ;
00051   cout<<"Same arrays, reverse order ... ";
00052   if ((ret=modulusArray3.compare(modulusArray))!=-1)
00053     cout << "Error : two arrays are in reverse order !"<<ret<<endl;
00054   else
00055     cout << "OK" <<endl;
00056 
00057   int array4[6]={1,2,1,0} ;
00058   MEDMODULUSARRAY modulusArray4(4,array4) ;
00059   cout<<"Different arrays size ... ";
00060   if ((ret=modulusArray4.compare(modulusArray))!=0)
00061     cout << "Error : two arrays have different size !"<<ret<<endl;
00062   else
00063     cout << "OK" <<endl;
00064   
00065   int array5[5]={1,2,1,0,1} ;
00066   MEDMODULUSARRAY modulusArray5(5,array5) ;
00067   cout<<"Different array, same size ... ";
00068   if ((ret=modulusArray5.compare(modulusArray))!=0)
00069     cout << "Error : two arrays are not be identical !"<<ret<<endl;
00070   else
00071     cout << "OK" <<endl;
00072  
00073   // test small array :
00074 
00075   // 1
00076   int array6[1]={1} ;
00077   MEDMODULUSARRAY modulusArray6(1,array6);
00078 
00079   cout<<"ModuloArray 1 :"<<endl;
00080   for(int i=-10;i<15;i++)
00081     cout <<"  - A["<<i<<"]="<<modulusArray6[i]<<endl;
00082   cout <<endl;
00083 
00084   int array7[1]={1} ;
00085   MEDMODULUSARRAY modulusArray7(1,array7);
00086   cout<<"Same arrays, same order ... ";
00087   if ((ret=modulusArray6.compare(modulusArray7))!=1)
00088     cout << "Error : two arrays are identical !"<<ret<<endl;
00089   else
00090     cout << "OK" <<endl;
00091   int array8[1]={2} ;
00092   MEDMODULUSARRAY modulusArray8(1,array8);
00093   cout<<"Different arrays ... ";
00094   if ((ret=modulusArray6.compare(modulusArray8))!=0)
00095     cout << "Error : two arrays are different !"<<ret<<endl;
00096   else
00097     cout << "OK" <<endl;
00098 
00099   
00100   // 2
00101   int array60[2]={1,2} ;
00102   MEDMODULUSARRAY modulusArray60(2,array60);
00103 
00104   cout<<"ModuloArray 2 :"<<endl;
00105   for(int i=-10;i<15;i++)
00106     cout <<"  - A["<<i<<"]="<<modulusArray60[i]<<endl;
00107   cout <<endl;
00108 
00109   int array70[2]={1,2} ;
00110   MEDMODULUSARRAY modulusArray70(2,array70);
00111   cout<<"Same arrays, same order ... ";
00112   if ((ret=modulusArray60.compare(modulusArray70))!=1)
00113     cout << "Error : two arrays are identical !"<<ret<<endl;
00114   else
00115     cout << "OK" <<endl;
00116   int array80[2]={2,2} ;
00117   MEDMODULUSARRAY modulusArray80(2,array80);
00118   cout<<"Different arrays ... ";
00119   if ((ret=modulusArray60.compare(modulusArray80))!=0)
00120     cout << "Error : two arrays are different !"<<ret<<endl;
00121   else
00122     cout << "OK" <<endl;
00123   int array90[2]={2,1} ;
00124   MEDMODULUSARRAY modulusArray90(2,array90);
00125   cout<<"Same arrays, reverse order ... ";
00126   if ((ret=modulusArray60.compare(modulusArray90))!=-1)
00127     cout << "Error : two arrays are in reverse order !"<<ret<<endl;
00128   else
00129     cout << "OK" <<endl;
00130 
00131   
00132 
00133  
00134 
00135   return 0 ;
00136 }