34 #define ETH_FUNC __FUNCSIG__ 35 #elif defined(__GNUC__) 36 #define ETH_FUNC __PRETTY_FUNCTION__ 38 #define ETH_FUNC __func__ 41 #define asserts(A) ::dev::assertAux(A, #A, __LINE__, __FILE__, ETH_FUNC) 42 #define assertsEqual(A, B) ::dev::assertEqualAux(A, B, #A, #B, __LINE__, __FILE__, ETH_FUNC) 44 inline bool assertAux(
bool _a,
char const* _aStr,
unsigned _line,
char const* _file,
char const* _func)
49 std::cerr <<
"Assertion failed:" << _aStr <<
" [func=" << _func <<
", line=" << _line <<
", file=" << _file <<
"]" << std::endl;
57 template<
class A,
class B>
58 inline bool assertEqualAux(A
const& _a, B
const& _b,
char const* _aStr,
char const* _bStr,
unsigned _line,
char const* _file,
char const* _func)
63 std::cerr <<
"Assertion failed: " << _aStr <<
" == " << _bStr <<
" [func=" << _func <<
", line=" << _line <<
", file=" << _file <<
"]" << std::endl;
64 std::cerr <<
" Fail equality: " << _a <<
"==" << _b << std::endl;
75 #define assertThrow(_condition, _ExceptionType, _description) \ 76 ::dev::assertThrowAux<_ExceptionType>(_condition, _description, __LINE__, __FILE__, ETH_FUNC) 80 template <
class _ExceptionType>
83 ::std::string
const& _errorDescription,
90 ::boost::throw_exception(
93 ::boost::throw_function(_function) <<
94 ::boost::throw_file(_file) <<
95 ::boost::throw_line(_line)
99 template <
class _ExceptionType>
101 void const* _pointer,
102 ::std::string
const& _errorDescription,
105 char const* _function
108 assertThrowAux<_ExceptionType>(_pointer !=
nullptr, _errorDescription, _line, _file, _function);
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
void assertThrowAux(bool _condition,::std::string const &_errorDescription, unsigned _line, char const *_file, char const *_function)
bool assertAux(bool _a, char const *_aStr, unsigned _line, char const *_file, char const *_func)
boost::error_info< struct tag_comment, std::string > errinfo_comment
bool assertEqualAux(A const &_a, B const &_b, char const *_aStr, char const *_bStr, unsigned _line, char const *_file, char const *_func)