test/test_tools.h
changeset 208 4317d277ba21
parent 171 02f4d5d9bfd7
child 209 765619b7cbb2
equal deleted inserted replaced
3:6934a15bc693 4:4878b2b5c6b8
    22 ///\ingroup misc
    22 ///\ingroup misc
    23 ///\file
    23 ///\file
    24 ///\brief Some utilities to write test programs.
    24 ///\brief Some utilities to write test programs.
    25 
    25 
    26 #include <iostream>
    26 #include <iostream>
       
    27 #include <stdlib.h>
    27 
    28 
    28 ///If \c rc is fail, writes an error message and exits.
    29 ///If \c rc is fail, writes an error message and exits.
    29 
    30 
    30 ///If \c rc is fail, writes an error message and exits.
    31 ///If \c rc is fail, writes an error message and exits.
    31 ///The error message contains the file name and the line number of the
    32 ///The error message contains the file name and the line number of the
    34 ///
    35 ///
    35 ///For example
    36 ///For example
    36 ///\code check(0==1,"This is obviously false.");\endcode will
    37 ///\code check(0==1,"This is obviously false.");\endcode will
    37 ///print something like this (and then exits).
    38 ///print something like this (and then exits).
    38 ///\verbatim file_name.cc:123: error: This is obviously false. \endverbatim
    39 ///\verbatim file_name.cc:123: error: This is obviously false. \endverbatim
    39 ///
       
    40 ///\todo It should be in \c assert.h
       
    41 #define check(rc, msg) \
    40 #define check(rc, msg) \
    42   if(!(rc)) { \
    41   if(!(rc)) { \
    43     std::cerr << __FILE__ ":" << __LINE__ << ": error: " << msg << std::endl; \
    42     std::cerr << __FILE__ ":" << __LINE__ << ": error: " << msg << std::endl; \
    44     abort(); \
    43     abort(); \
    45   } else { } \
    44   } else { } \