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