CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
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
21#include "CLHEP/Exceptions/ZMthrow.h"
22#include "CLHEP/Exceptions/ZMexception.h"
23#include "CLHEP/Exceptions/ZMexAction.h"
24#include "CLHEP/Exceptions/ZMexClassInfo.h"
25#include "CLHEP/Exceptions/ZMexSeverity.h"
26#include "CLHEP/Exceptions/ZMerrno.h"
27
28
29// remove the above line to test with namespace on.
30
31// ----------
32// Define exception classes and default behaviors:
33// ----------
34
36zmex::ZMexClassInfo ZMxTest::_classInfo(
37 "ZMxTest", "Test", zmex::ZMexSEVERE );
38
39
40// ----------
41// Define output formats, etc
42// ----------
43
44const string QUOTE = "\"";
45const string NEWLINE1 = "\n";
46const string NEWLINE2 = "\n\n";
47
48void display( const zmex::ZMexception * ex ) {
49
51 + ex->name() + ": " + QUOTE + ex->message() + QUOTE + NEWLINE1
52 + " " + (ex->wasThrown() ? "thrown" : "ignored")
53 + " by " + ex->handlerUsed() + "()" + NEWLINE1
54 );
55
56}
57
58
59int main() {
60
61 // ----------
62 // Begin testing, check out basic logger:
63 // ----------
65 zmex::ZMlogger().emit( "---------- Begin testing: ----------\n" );
67 zmex::ZMlogger().emit( "This message checks out basic logger behavior\n" );
68
69 ZMthrow( ZMxTest( "Testing exception behavior" ) );
70
71 // ----------
72 // Done, go home
73 // ----------
74 return 0;
75
76} // main()
#define ZMexStandardDefinition(Parent, Class)
Definition: ZMexception.h:523
#define ZMthrow(userExcept)
Definition: ZMthrow.h:97
ZMexLogResult emit(const ZMexception &exc)
Definition: ZMexLogger.cc:255
std::string handlerUsed() const
std::string message() const
bool wasThrown() const
virtual std::string name() const
Definition: ZMexception.cc:106
ZMexLogger & ZMlogger()
Definition: ZMexception.cc:70
@ ZMexSEVERE
Definition: ZMexSeverity.h:53
void display(const zmex::ZMexception *ex)
Definition: testzmex.cc:48
const string QUOTE
Definition: testzmex.cc:44
const string NEWLINE2
Definition: testzmex.cc:46
const string NEWLINE1
Definition: testzmex.cc:45
int main()
Definition: testzmex.cc:59