]> Creatis software - gdcm.git/blob - Testing/TestException.cxx
I tried to make a Test for gdcm::Exception
[gdcm.git] / Testing / TestException.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestException.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/02/11 16:42:23 $
7   Version:   $Revision: 1.1 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmException.h"
20 #include "gdcmDebug.h"
21 #include "gdcmGlobal.h"
22 #include "gdcmCommon.h"
23
24 struct myException
25 {
26    std::string error;
27
28    myException( std::string ErrorMessage )
29    {
30       error = ErrorMessage;
31    }
32    void Print() { std::cerr << "Pfff!" << error << std::endl; }
33 };
34
35
36
37 void functionForException()  throw ( myException );
38   
39 void functionForException() 
40      throw ( myException )
41 {
42       throw myException("in functionForException : ");
43 }
44
45
46
47
48 int TestException(int , char **)
49 {  
50    try
51    {
52       functionForException();
53    }
54    catch (myException)
55    {
56       std::cout << "Exception 'myException' received" << std::endl;
57    }
58
59 return 0;
60 }