/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/ers/ers-00-00-03/test/test.cxx File Reference

#include "ers/ers.h"
#include "ExampleIssue.h"

Go to the source code of this file.

Functions

void foo (int n)
void massive_test ()
int main (int argc, char **argv)


Function Documentation

void foo ( int  n  ) 

This function illustrates the usage of range checking macros.

Parameters:
n an integer excepted to be between 0 and 42.

Definition at line 26 of file test.cxx.

References ERS_DEBUG_0, and ERS_RANGE_CHECK.

Referenced by main().

00026                 {
00027     ERS_RANGE_CHECK(0,n,42) ; 
00028     ERS_DEBUG_0("function foo called with value %d",n);
00029 } // foo

int main ( int  argc,
char **  argv 
)

Definition at line 39 of file test.cxx.

References ers::Context::add_qualifier(), ers::debug_3, ers::StreamFactory::dispatch(), ers::error, ERS_DEBUG_0, ERS_DEBUG_3, ERS_HERE, ERS_STATIC_ASSERT, foo(), genRecEmupikp::i, massive_test(), ers::StreamFactory::set_stream(), ers::StreamFactory::warning(), and ers::warning.

00039                                 {
00040     for(int i=1;i<argc;i++) { // we add all parameters as qualifiers
00041         ers::Context::add_qualifier(argv[i]) ; 
00042     } // 
00043     ers::Context::add_qualifier("ers_test") ;   // we add a qualifier to all issues 
00044     try { // We need to work with a try/catch block 
00045         massive_test(); 
00046         ers::StreamFactory::set_stream(ers::debug_3,"filter:?!ers_test,ers_failure@default"); // we filter out all issue with qualifier ers_test at level debug_3
00047         ERS_DEBUG_3("This should not be displayed"); 
00048         ERS_DEBUG_0("checking static assert");
00049         ERS_STATIC_ASSERT(sizeof(int)==4);            
00050         ERS_DEBUG_0("dispatching custom issue to warning stream"); 
00051         ExampleIssue issue(ERS_HERE,ers::warning,10); // we build an instance of our Issue
00052         ers::StreamFactory::dispatch(issue);   // dispatch sends it to the correct stream based on severity
00053         ERS_DEBUG_0("calling a method with wrong range"); 
00054         foo(43); 
00055         ERS_DEBUG_0("done - if we reached this point, assertion have been disabled - this can be done by defining the N_DEBUG macro");
00056         ERS_DEBUG_0("throwing custom issue");
00057         throw ExampleIssue(ERS_HERE,ers::error,25); 
00058     } catch (ers::Issue &e) { // we catch issues and send them to the warning stream 
00059         ers::StreamFactory::warning(&e); 
00060     }
00061     return 0 ; 
00062 } // main 

void massive_test (  ) 

Definition at line 31 of file test.cxx.

References ers::debug_2, ERS_DEBUG_0, ERS_DEBUG_2, genRecEmupikp::i, and ers::StreamFactory::set_stream().

Referenced by main().

00031                     { 
00032     ers::StreamFactory::set_stream(ers::debug_2,"null");
00033     ERS_DEBUG_0("dumping a lot of log issues"); 
00034     for(int i=0;i<1000000;i++) {
00035         ERS_DEBUG_2("dump %d",i); 
00036     } // for 
00037 } // 


Generated on Tue Nov 29 23:14:56 2016 for BOSS_7.0.2 by  doxygen 1.4.7