File: testzmex.cc

package info (click to toggle)
clhep 2.1.4.1%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,012 kB
  • sloc: cpp: 50,094; sh: 6,694; makefile: 2,694; perl: 28
file content (73 lines) | stat: -rwxr-xr-x 1,720 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// ----------------------------------------------------------------------
//
// testzmex.cc - test whether namespaces work out.
//
// History:
//	04/13/01 mf	wrote
//
//
// usage:  Place into src and test makefile
// override CPPFLAGS += -DZM_USE_NAMESPACES
// and build.
// ----------------------------------------------------------------------



#include <string>
  using std::string;

#include "CLHEP/Cast/itos.h"

#include "CLHEP/Exceptions/ZMthrow.h"
#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/Exceptions/ZMerrno.h"


// remove the above line to test with namespace on.

// ----------
// Define exception classes and default behaviors:
// ----------

ZMexStandardDefinition( zmex::ZMexception, ZMxTest );
zmex::ZMexClassInfo ZMxTest::_classInfo(
  "ZMxTest", "Test", zmex::ZMexSEVERE );


// ----------
// Define output formats, etc
// ----------

const string QUOTE    = "\"";
const string NEWLINE1 = "\n";
const string NEWLINE2 = "\n\n";

void display( const zmex::ZMexception * ex )  {

  zmex::ZMlogger().emit( NEWLINE1
               + ex->name() + ": " + QUOTE + ex->message() + QUOTE + NEWLINE1
               + "  " + (ex->wasThrown() ? "thrown" : "ignored")
               + " by " + ex->handlerUsed() + "()" + NEWLINE1
               );

}


int main()  {

  // ----------
  // Begin testing, check out basic logger:
  // ----------
  zmex::ZMlogger().emit( NEWLINE1 );
  zmex::ZMlogger().emit( "----------  Begin testing:  ----------\n" );
  zmex::ZMlogger().emit( NEWLINE1 );
  zmex::ZMlogger().emit( "This message checks out basic logger behavior\n" );

  ZMthrow( ZMxTest( "Testing exception behavior" ) );

  // ----------
  // Done, go home
  // ----------
  return 0;

}  // main()