27 #include <boost/exception/info.hpp>
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)
47 std::cerr <<
"Assertion failed:" << _aStr <<
" [func=" << _func <<
", line=" << _line <<
", file=" << _file <<
"]" << std::endl;
51 template<
class A,
class B>
52 inline bool assertEqualAux(A
const& _a, B
const& _b,
char const* _aStr,
char const* _bStr,
unsigned _line,
char const* _file,
char const* _func)
57 std::cerr <<
"Assertion failed: " << _aStr <<
" == " << _bStr <<
" [func=" << _func <<
", line=" << _line <<
", file=" << _file <<
"]" << std::endl;
58 std::cerr <<
" Fail equality: " << _a <<
"==" << _b << std::endl;
66 #define assertThrow(_condition, _ExceptionType, _description) \
67 ::dev::assertThrowAux<_ExceptionType>(_condition, _description, __LINE__, __FILE__, ETH_FUNC)
71 template <
class _ExceptionType>
74 ::std::string
const& _errorDescription,
81 ::boost::throw_exception(
84 ::boost::throw_function(_function) <<
85 ::boost::throw_file(_file) <<
86 ::boost::throw_line(_line)
90 template <
class _ExceptionType>
93 ::std::string
const& _errorDescription,
99 assertThrowAux<_ExceptionType>(_pointer !=
nullptr, _errorDescription, _line, _file, _function);