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
33zmex::ZMexClassInfo ZMxTest::_classInfo(
34 "ZMxTest", "Test", zmex::ZMexSEVERE );
35
36
37// ----------
38// Define output formats, etc
39// ----------
40
41const string QUOTE = "\"";
42const string NEWLINE1 = "\n";
43const string NEWLINE2 = "\n\n";
44
45void 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
56int 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()
#define ZMexStandardDefinition(Parent, Class)
#define ZMthrow(userExcept)
ZMexLogResult emit(const ZMexception &exc)
std::string handlerUsed() const
std::string message() const
bool wasThrown() const
virtual std::string name() const
ZMexLogger & ZMlogger()
void display(const zmex::ZMexception *ex)
Definition testzmex.cc:45
const string QUOTE
Definition testzmex.cc:41
const string NEWLINE2
Definition testzmex.cc:43
const string NEWLINE1
Definition testzmex.cc:42
int main()
Definition testzmex.cc:56