Salome HOME
sources v1.2
[modules/med.git] / src / MEDMEM / tests / testUUnit.cxx
1 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 //
20 //
21 //
22 //  File   : testUUnit.cxx
23 //  Module : MED
24
25 using namespace std;
26 #include <cstdlib>
27 #include <exception>
28
29 #include "MEDMEM_Unit.hxx"
30
31 int main (int argc, char ** argv)
32 {
33
34   cout << "UNIT Test" << endl ;
35   cout << "---------" << endl;
36
37   UNIT testu;
38   try
39   {
40         testu.setName("ForTesting") ;
41   }
42   catch ( const std::exception &e )
43   {
44         cout << "-----------------" << endl;
45         cout << " pb avec setName " << endl;
46         cout << "-----------------" << endl;
47         MESSAGE( "catched exception : " << e.what() ) ;
48         return EXIT_FAILURE ;
49   }
50   catch (...)
51   {
52         cout << "-----------------" << endl;
53         cout << " pb avec setName " << endl;
54         cout << "-----------------" << endl;
55         return EXIT_FAILURE ;
56   }
57
58   try
59   {
60         testu.setDescription("all values are setted 10") ;
61   }
62   catch ( const std::exception &e )
63   {
64         cout << "------------------------" << endl;
65         cout << " pb avec setDescription " << endl;
66         cout << "------------------------" << endl;
67         MESSAGE( "catched exception : " << e.what() ) ;
68         return EXIT_FAILURE ;
69   }
70   catch (...)
71   {
72         cout << "------------------------" << endl;
73         cout << " pb avec setDescription " << endl;
74         cout << "------------------------" << endl;
75         return EXIT_FAILURE ;
76   }
77
78   try
79   {
80         testu.setMasse(10);
81   }
82   catch ( const std::exception &e )
83   {
84         cout << "------------------" << endl;
85         cout << " pb avec setMasse " << endl;
86         cout << "------------------" << endl;
87         MESSAGE( "catched exception : " << e.what() ) ;
88         return EXIT_FAILURE ;
89   }
90   catch (...)
91   {
92         cout << "------------------" << endl;
93         cout << " pb avec setMasse " << endl;
94         cout << "------------------" << endl;
95         return EXIT_FAILURE ;
96   }
97
98   try
99   {
100         testu.setLength(10);
101   }
102   catch ( const std::exception &e )
103   {
104         cout << "-------------------" << endl;
105         cout << " pb avec setLength " << endl;
106         cout << "-------------------" << endl;
107         MESSAGE( "catched exception : " << e.what() ) ;
108         return EXIT_FAILURE ;
109   }
110   catch (...)
111   {
112         cout << "-------------------" << endl;
113         cout << " pb avec setLength " << endl;
114         cout << "-------------------" << endl;
115         return EXIT_FAILURE ;
116   }
117
118   try
119   {
120         testu.setTime(10);
121   }
122   catch ( const std::exception &e )
123   {
124         cout << "-----------------" << endl;
125         cout << " pb avec setTime " << endl;
126         cout << "-----------------" << endl;
127         MESSAGE( "catched exception : " << e.what() ) ;
128         return EXIT_FAILURE ;
129   }
130   catch (...)
131   {
132         cout << "-----------------" << endl;
133         cout << " pb avec setTime " << endl;
134         cout << "-----------------" << endl;
135         return EXIT_FAILURE ;
136   }
137
138   try
139   {
140         testu.setTemperature(10);
141   }
142   catch ( const std::exception &e )
143   {
144         cout << "------------------------" << endl;
145         cout << " pb avec setTemperature " << endl;
146         cout << "------------------------" << endl;
147         MESSAGE( "catched exception : " << e.what() ) ;
148         return EXIT_FAILURE ;
149   }
150   catch (...)
151   {
152         cout << "------------------------" << endl;
153         cout << " pb avec setTemperature " << endl;
154         cout << "------------------------" << endl;
155         return EXIT_FAILURE ;
156   }
157
158   try
159   {
160         testu.setMatterQuantity(10);
161   }
162   catch ( const std::exception &e )
163   {
164         cout << "---------------------------" << endl;
165         cout << " pb avec setMatterQuantity " << endl;
166         cout << "---------------------------" << endl;
167         MESSAGE( "catched exception : " << e.what() ) ;
168         return EXIT_FAILURE ;
169   }
170   catch (...)
171   {
172         cout << "---------------------------" << endl;
173         cout << " pb avec setMatterQuantity " << endl;
174         cout << "---------------------------" << endl;
175         return EXIT_FAILURE ;
176   }
177
178   try
179   {
180         testu.setCurrentStrength(10) ;
181   }
182   catch ( const std::exception &e )
183   {
184         cout << "---------------------------" << endl;
185         cout << " pb avec setCurrentStrengt " << endl;
186         cout << "---------------------------" << endl;
187         MESSAGE( "catched exception : " << e.what() ) ;
188         return EXIT_FAILURE ;
189   }
190   catch (...)
191   {
192         cout << "---------------------------" << endl;
193         cout << " pb avec setCurrentStrengt " << endl;
194         cout << "---------------------------" << endl;
195         return EXIT_FAILURE ;
196   }
197
198   try
199   {
200         testu.setLightIntensity(10) ;
201   }
202   catch ( const std::exception &e )
203   {
204         cout << "---------------------------" << endl;
205         cout << " pb avec setLightIntensity " << endl;
206         cout << "---------------------------" << endl;
207         MESSAGE( "catched exception : " << e.what() ) ;
208         return EXIT_FAILURE ;
209   }
210   catch (...)
211   {
212         cout << "---------------------------" << endl;
213         cout << " pb avec setLightIntensity " << endl;
214         cout << "---------------------------" << endl;
215         return EXIT_FAILURE ;
216   }
217
218
219   try
220   {
221         cout << testu.getName() << endl ;
222   }
223   catch ( const std::exception &e )
224   {
225         cout << "-----------------" << endl;
226         cout << " pb avec getName " << endl;
227         cout << "-----------------" << endl;
228         MESSAGE( "catched exception : " << e.what() ) ;
229         return EXIT_FAILURE ;
230   }
231   catch (...)
232   {
233         cout << "-----------------" << endl;
234         cout << " pb avec getName " << endl;
235         cout << "-----------------" << endl;
236         return EXIT_FAILURE ;
237   }
238
239   try
240   {
241         cout << testu.getDescription() << endl ;
242   }
243   catch ( const std::exception &e )
244   {
245         cout << "------------------------" << endl;
246         cout << " pb avec getDescription " << endl;
247         cout << "------------------------" << endl;
248         MESSAGE( "catched exception : " << e.what() ) ;
249         return EXIT_FAILURE ;
250   }
251   catch (...)
252   {
253         cout << "------------------------" << endl;
254         cout << " pb avec getDescription " << endl;
255         cout << "------------------------" << endl;
256         return EXIT_FAILURE ;
257   }
258
259   try
260   {
261         cout << testu.getMasse() << endl ;
262   }
263   catch ( const std::exception &e )
264   {
265         cout << "------------------" << endl;
266         cout << " pb avec getMasse " << endl;
267         cout << "------------------" << endl;
268         MESSAGE( "catched exception : " << e.what() ) ;
269         return EXIT_FAILURE ;
270   }
271   catch (...)
272   {
273         cout << "------------------" << endl;
274         cout << " pb avec getMasse " << endl;
275         cout << "------------------" << endl;
276         return EXIT_FAILURE ;
277   }
278
279   try
280   {
281         cout << testu.getLength() << endl ;
282   }
283   catch ( const std::exception &e )
284   {
285         cout << "-------------------" << endl;
286         cout << " pb avec getLength " << endl;
287         cout << "-------------------" << endl;
288         MESSAGE( "catched exception : " << e.what() ) ;
289         return EXIT_FAILURE ;
290   }
291   catch (...)
292   {
293         cout << "-------------------" << endl;
294         cout << " pb avec getLength " << endl;
295         cout << "-------------------" << endl;
296         return EXIT_FAILURE ;
297   }
298
299   try
300   {
301         cout << testu.getTime() << endl ;
302   }
303   catch ( const std::exception &e )
304   {
305         cout << "-----------------" << endl;
306         cout << " pb avec getTime " << endl;
307         cout << "-----------------" << endl;
308         MESSAGE( "catched exception : " << e.what() ) ;
309         return EXIT_FAILURE ;
310   }
311   catch (...)
312   {
313         cout << "-----------------" << endl;
314         cout << " pb avec getTime " << endl;
315         cout << "-----------------" << endl;
316         return EXIT_FAILURE ;
317   }
318
319   try
320   {
321         cout << testu.getTemperature() << endl ;
322   }
323   catch ( const std::exception &e )
324   {
325         cout << "------------------------" << endl;
326         cout << " pb avec getTemperature " << endl;
327         cout << "------------------------" << endl;
328         MESSAGE( "catched exception : " << e.what() ) ;
329         return EXIT_FAILURE ;
330   }
331   catch (...)
332   {
333         cout << "------------------------" << endl;
334         cout << " pb avec getTemperature " << endl;
335         cout << "------------------------" << endl;
336         return EXIT_FAILURE ;
337   }
338
339   try
340   {
341         cout << testu.getMatterQuantity() << endl ;
342   }
343   catch ( const std::exception &e )
344   {
345         cout << "---------------------------" << endl;
346         cout << " pb avec getMatterQuantity " << endl;
347         cout << "---------------------------" << endl;
348         MESSAGE( "catched exception : " << e.what() ) ;
349         return EXIT_FAILURE ;
350   }
351   catch (...)
352   {
353         cout << "---------------------------" << endl;
354         cout << " pb avec getMatterQuantity " << endl;
355         cout << "---------------------------" << endl;
356         return EXIT_FAILURE ;
357   }
358
359   try
360   {
361         cout << testu.getCurrentStrength() << endl ;
362   }
363   catch ( const std::exception &e )
364   {
365         cout << "----------------------------" << endl;
366         cout << " pb avec getCurrentStrength " << endl;
367         cout << "----------------------------" << endl;
368         MESSAGE( "catched exception : " << e.what() ) ;
369         return EXIT_FAILURE ;
370   }
371   catch (...)
372   {
373         cout << "----------------------------" << endl;
374         cout << " pb avec getCurrentStrength " << endl;
375         cout << "----------------------------" << endl;
376         return EXIT_FAILURE ;
377   }
378
379   try
380   {
381         cout << testu.getLightIntensity() << endl ;
382   }
383   catch ( const std::exception &e )
384   {
385         cout << "---------------------------" << endl;
386         cout << " pb avec getLightIntensity " << endl;
387         cout << "---------------------------" << endl;
388         MESSAGE( "catched exception : " << e.what() ) ;
389         return EXIT_FAILURE ;
390   }
391   catch (...)
392   {
393         cout << "---------------------------" << endl;
394         cout << " pb avec getLightIntensity " << endl;
395         cout << "---------------------------" << endl;
396         return EXIT_FAILURE ;
397   }
398
399   return EXIT_SUCCESS ;
400
401 } ;