CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

testzmex.cc
Go to the documentation of this file.
1 // ----------------------------------------------------------------------
2 //
3 // testzmex.cc - test whether namespaces work out.
4 //
5 // History:
6 // 04/13/01 mf wrote
7 //
8 //
9 // usage: Place into src and test makefile
10 // override CPPFLAGS += -DZM_USE_NAMESPACES
11 // and build.
12 // ----------------------------------------------------------------------
13 
14 
15 
16 #include <string>
17  using std::string;
18 
19 #include "CLHEP/Cast/itos.h"
20 
24 
25 
26 // remove the above line to test with namespace on.
27 
28 // ----------
29 // Define exception classes and default behaviors:
30 // ----------
31 
33 zmex::ZMexClassInfo ZMxTest::_classInfo(
34  "ZMxTest", "Test", zmex::ZMexSEVERE );
35 
36 
37 // ----------
38 // Define output formats, etc
39 // ----------
40 
41 const string QUOTE = "\"";
42 const string NEWLINE1 = "\n";
43 const string NEWLINE2 = "\n\n";
44 
45 void display( const zmex::ZMexception * ex ) {
46 
48  + ex->name() + ": " + QUOTE + ex->message() + QUOTE + NEWLINE1
49  + " " + (ex->wasThrown() ? "thrown" : "ignored")
50  + " by " + ex->handlerUsed() + "()" + NEWLINE1
51  );
52 
53 }
54 
55 
56 int main() {
57 
58  // ----------
59  // Begin testing, check out basic logger:
60  // ----------
62  zmex::ZMlogger().emit( "---------- Begin testing: ----------\n" );
64  zmex::ZMlogger().emit( "This message checks out basic logger behavior\n" );
65 
66  ZMthrow( ZMxTest( "Testing exception behavior" ) );
67 
68  // ----------
69  // Done, go home
70  // ----------
71  return 0;
72 
73 } // main()
const string NEWLINE1
std::string message() const
ZMexLogResult emit(const ZMexception &exc)
Definition: ZMexLogger.cc:252
ZMexLogger & ZMlogger()
Definition: ZMexception.cc:68
void display(const ZMexception *ex)
const string QUOTE
#define ZMexStandardDefinition(Parent, Class)
bool wasThrown() const
const string NEWLINE2
#define ZMthrow(userExcept)
virtual std::string name() const
Definition: ZMexception.cc:104
std::string handlerUsed() const
int main()
Definition: testBug66214.cc:30