From: jpr Date: Fri, 11 Feb 2005 16:42:23 +0000 (+0000) Subject: I tried to make a Test for gdcm::Exception X-Git-Tag: Version1.0.bp~26 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f711022dedd779e5e58e649af8c440a4a58bdba1;p=gdcm.git I tried to make a Test for gdcm::Exception I never could even compile. Replace by myExecption ... How can it work? --- diff --git a/Testing/TestException.cxx b/Testing/TestException.cxx new file mode 100644 index 00000000..312ed87e --- /dev/null +++ b/Testing/TestException.cxx @@ -0,0 +1,60 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: TestException.cxx,v $ + Language: C++ + Date: $Date: 2005/02/11 16:42:23 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "gdcmException.h" +#include "gdcmDebug.h" +#include "gdcmGlobal.h" +#include "gdcmCommon.h" + +struct myException +{ + std::string error; + + myException( std::string ErrorMessage ) + { + error = ErrorMessage; + } + void Print() { std::cerr << "Pfff!" << error << std::endl; } +}; + + + +void functionForException() throw ( myException ); + +void functionForException() + throw ( myException ) +{ + throw myException("in functionForException : "); +} + + + + +int TestException(int , char **) +{ + try + { + functionForException(); + } + catch (myException) + { + std::cout << "Exception 'myException' received" << std::endl; + } + +return 0; +}