Salome HOME
Copyright update 2021
[tools/medcoupling.git] / src / INTERP_KERNELTest / InterpolationPlanarTestSuite.hxx
1 // Copyright (C) 2007-2021  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef __TU_INTERPOLATION_PLANAR_TEST_SUITE_HXX__
21 #define __TU_INTERPOLATION_PLANAR_TEST_SUITE_HXX__
22
23 #include <cppunit/extensions/HelperMacros.h>
24 #include <deque>
25 #include <cmath>
26 #include <iostream>
27
28 namespace INTERP_TEST
29 {
30
31   /**
32    * \brief Base class for planar mesh intersection test suites.
33    * 
34    */
35   class InterpolationPlanarTestSuite : public CppUnit::TestFixture
36   {
37
38   public:
39     double _Epsilon;
40     double _Precision;
41
42     /**
43      * Sets up the test suite.
44      *
45      */
46     void setUp()
47     {
48       _Epsilon = 1.e-6;
49       _Precision = 1.e-6;
50     }
51     void tearDown()  {}
52
53     //     bool checkDequesEqual(std::deque< double > deque1, std::deque< double > deque2, double epsilon);
54     //     bool checkVectorsEqual(std::vector< double > Vect1, std::vector< double > Vect2, double epsilon);
55     //     void dequePrintOut(std::deque< double > deque1);
56     //     void vectPrintOut(std::vector< double > vect);
57     //     void tabPrintOut( const double * tab, int size);
58
59     bool checkDequesEqual(std::deque< double > deque1,  
60                           std::deque< double > deque2, double epsilon)
61     {
62       std::size_t size1 = deque1.size();
63       std::size_t size2 = deque2.size();
64       bool are_equal = size1 == size2;
65     
66       if(are_equal)
67         for(std::size_t i = 0; i < size1 && are_equal; i++)
68           are_equal = fabs(deque1[i] - deque2[i]) < epsilon;
69       
70       return are_equal; 
71     }
72     bool checkVectorsEqual(std::vector< double > vect1,  
73                            std::vector< double > vect2, double epsilon)
74     {
75       std::size_t size1 = vect1.size();
76       std::size_t size2 = vect2.size();
77       bool are_equal = size1 == size2;
78       
79       if(are_equal)
80         for(std::size_t i = 0; i < size1 && are_equal; i++)
81           are_equal = fabs(vect1[i] - vect2[i]) < epsilon;
82       
83       return are_equal; 
84     }
85     void dequePrintOut(std::deque< double > deque1)
86     {
87       for(std::size_t i = 0; i< deque1.size(); i++)
88         {
89           std::cerr << deque1[i] << " ";
90         }
91       std::cerr<< std::endl;
92     }
93     void vectPrintOut(std::vector< double > vect)
94     {
95       for(std::size_t i = 0; i< vect.size(); i++)
96         {
97           std::cerr << vect[i] << " ";
98         }
99       std::cerr<< std::endl;
100     }  
101     void tabPrintOut( const double * tab,int size)
102     {
103       for(int i = 0; i< size; i++)
104         {
105           std::cerr << tab[i] << " ";
106         }
107       std::cerr<< std::endl;
108     }  
109
110     /**
111      * Cleans up after the test suite.
112      * Liberates the MeshTestToolkit object used by the tests.
113      */
114     //     void tearDown()
115     //     {
116     //       delete _testTools;
117     //     }
118
119     
120
121     //   protected:
122     //     /// MeshTestToolkit object to which the tests are delegated
123     //     MeshTestToolkit* _testTools; 
124
125   };
126 }
127 #endif