CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
Exceptions
test
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/ZMerrno.h
"
24
25
26
// remove the above line to test with namespace on.
27
28
// ----------
29
// Define exception classes and default behaviors:
30
// ----------
31
32
ZMexStandardDefinition
(
zmex::ZMexception
, ZMxTest );
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
47
zmex::ZMlogger
().
emit
(
NEWLINE1
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
// ----------
61
zmex::ZMlogger
().
emit
(
NEWLINE1
);
62
zmex::ZMlogger
().
emit
(
"---------- Begin testing: ----------\n"
);
63
zmex::ZMlogger
().
emit
(
NEWLINE1
);
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()
ZMthrow
#define ZMthrow(userExcept)
Definition:
CLHEP/Exceptions/ZMthrow.h:97
ZMexStandardDefinition
ZMexStandardDefinition(zmex::ZMexception, ZMxTest)
ZMthrow.h
zmex::ZMexception::handlerUsed
std::string handlerUsed() const
zmex::ZMexception::name
virtual std::string name() const
Definition:
ZMexception.cc:104
zmex::ZMexception
Definition:
CLHEP/Exceptions/ZMexception.h:163
ZMerrno.h
zmex::ZMexClassInfo
Definition:
CLHEP/Exceptions/ZMexClassInfo.h:94
zmex::ZMlogger
ZMexLogger & ZMlogger()
Definition:
ZMexception.cc:68
QUOTE
const string QUOTE
Definition:
testzmex.cc:41
NEWLINE2
const string NEWLINE2
Definition:
testzmex.cc:43
zmex::ZMexSEVERE
@ ZMexSEVERE
Definition:
CLHEP/Exceptions/ZMexSeverity.h:53
zmex::ZMexception::wasThrown
bool wasThrown() const
NEWLINE1
const string NEWLINE1
Definition:
testzmex.cc:42
ZMexception.h
zmex::ZMexception::message
std::string message() const
main
int main()
Definition:
testzmex.cc:56
display
void display(const zmex::ZMexception *ex)
Definition:
testzmex.cc:45
zmex::ZMexLogger::emit
ZMexLogResult emit(const ZMexception &exc)
Definition:
ZMexLogger.cc:252
Generated by
1.8.17