All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ExceptionsTest.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // STD & STL
5 // ============================================================================
6 #include <math.h>
7 #include <stdio.h>
8 #include <iostream>
9 #include <exception>
10 // ============================================================================
11 // GaudiKernel
12 // ============================================================================
15 // ============================================================================
16 // GaudiMath
17 // ============================================================================
18 #include "GaudiMath/GaudiMath.h"
19 // ============================================================================
20 // CLHEP
21 // ============================================================================
22 #include "CLHEP/GenericFunctions/Sin.hh"
23 // ============================================================================
24 // Handle CLHEP 2.0.x move to CLHEP namespace
25 namespace CLHEP { }
26 using namespace CLHEP;
27 
28 // ============================================================================
36 // ============================================================================
37 
38 int main()
39 {
40 
41  std::cout <<
42  " Test for embedded exceptions ( 2 exception shoudl be catched) "
43  << std::endl ;
44 
45  try {
46  const GaudiMath::Function& mysin = Genfun::Sin();
47  // the exception!!! showl be thrown!
48  const GaudiMath::Function& prim = GaudiMath::Derivative( mysin , 5 );
49  std::cout << "One should never see this line!! " << std::endl ;
50  mysin + prim ;
51  }
52  catch( const std::exception& e )
53  {
54  std::cout << " OK 1) The exception is catched with 'what'='"
55  << e.what() << "'" << std::endl;
56  }
57 
58  try {
59  const GaudiMath::Function& mysin = Genfun::Sin();
60  // the exception!!! showl be thrown!
61  const GaudiMath::Function& prim = GaudiMath::Derivative( mysin , 10 );
62  std::cout << "One should never see this line!! " << std::endl ;
63  mysin + prim ;
64  }
65  catch( const GaudiException& e )
66  {
67  std::cout << " OK 2) " << e << std::endl ;
68  }
69 
70  exit(0);
71 
72 }
73 
74 // ============================================================================
75 // The END
76 // ============================================================================
Define general base for Gaudi exception.
T endl(T...args)
Genfun::AbsFunction Function
Definition: GaudiMath.h:24
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:29
T what(T...args)
STL class.
int main()