CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

testzmex.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------
00002 //
00003 // testzmex.cc - test whether namespaces work out.
00004 //
00005 // History:
00006 //      04/13/01 mf     wrote
00007 //
00008 //
00009 // usage:  Place into src and test makefile
00010 // override CPPFLAGS += -DZM_USE_NAMESPACES
00011 // and build.
00012 // ----------------------------------------------------------------------
00013 
00014 
00015 
00016 #include <string>
00017   using std::string;
00018 
00019 #include "CLHEP/Cast/itos.h"
00020 
00021 #include "CLHEP/Exceptions/ZMthrow.h"
00022 #include "CLHEP/Exceptions/ZMexception.h"
00023 #include "CLHEP/Exceptions/ZMerrno.h"
00024 
00025 
00026 // remove the above line to test with namespace on.
00027 
00028 // ----------
00029 // Define exception classes and default behaviors:
00030 // ----------
00031 
00032 ZMexStandardDefinition( zmex::ZMexception, ZMxTest );
00033 zmex::ZMexClassInfo ZMxTest::_classInfo(
00034   "ZMxTest", "Test", zmex::ZMexSEVERE );
00035 
00036 
00037 // ----------
00038 // Define output formats, etc
00039 // ----------
00040 
00041 const string QUOTE    = "\"";
00042 const string NEWLINE1 = "\n";
00043 const string NEWLINE2 = "\n\n";
00044 
00045 void display( const zmex::ZMexception * ex )  {
00046 
00047   zmex::ZMlogger().emit( NEWLINE1
00048                + ex->name() + ": " + QUOTE + ex->message() + QUOTE + NEWLINE1
00049                + "  " + (ex->wasThrown() ? "thrown" : "ignored")
00050                + " by " + ex->handlerUsed() + "()" + NEWLINE1
00051                );
00052 
00053 }
00054 
00055 
00056 int main()  {
00057 
00058   // ----------
00059   // Begin testing, check out basic logger:
00060   // ----------
00061   zmex::ZMlogger().emit( NEWLINE1 );
00062   zmex::ZMlogger().emit( "----------  Begin testing:  ----------\n" );
00063   zmex::ZMlogger().emit( NEWLINE1 );
00064   zmex::ZMlogger().emit( "This message checks out basic logger behavior\n" );
00065 
00066   ZMthrow( ZMxTest( "Testing exception behavior" ) );
00067 
00068   // ----------
00069   // Done, go home
00070   // ----------
00071   return 0;
00072 
00073 }  // main()

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7