CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
Main Page
Namespaces
Classes
Files
File List
File Members
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()
Generated on Mon May 6 2013 04:04:12 for CLHEP by
1.8.1.2