#include "MHO_Message.hh"
#include <cmath>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>
Go to the source code of this file.
◆ CHECK_CLOSE
| #define CHECK_CLOSE |
( |
|
a, |
|
|
|
b, |
|
|
|
tol |
|
) |
| |
Value: do \
{ \
if(std::fabs((a) - (b)) > (tol)) \
{ \
std::cerr << "FAIL: |" #a " - " #b "| > " #tol " @ " << __FILE__ << ":" << __LINE__ << " (" << (a) << " vs " \
<< (b) << ")" << std::endl; \
return 1; \
} \
} \
while(0)
◆ HOPS_ASSERT_EQUAL
| #define HOPS_ASSERT_EQUAL |
( |
|
a, |
|
|
|
b |
|
) |
| |
Value: { \
if((a) != (b)) \
{ \
throw std::runtime_error(std::string(__FILE__) + std::string(":") + std::to_string(__LINE__) + \
std::string(" in ") + std::string(__PRETTY_FUNCTION__) + std::string(": ") + \
std::to_string((a)) + std::string(" != ") + std::to_string((b))); \
} \
}
◆ HOPS_ASSERT_FLOAT_LESS_THAN
| #define HOPS_ASSERT_FLOAT_LESS_THAN |
( |
|
a, |
|
|
|
b |
|
) |
| |
Value: { \
std::stringstream ssa; \
ssa << a; \
std::stringstream ssb; \
ssb << b; \
if((a) > (b)) \
{ \
throw std::runtime_error(std::string(__FILE__) + std::string(":") + std::to_string(__LINE__) + \
std::string(" in ") + std::string(__PRETTY_FUNCTION__) + std::string(": ") + ssa.str() + \
std::string(" !< ") + ssb.str()); \
} \
}
◆ HOPS_ASSERT_THROW
| #define HOPS_ASSERT_THROW |
( |
|
test_cond | ) |
|
Value: { \
if(!(test_cond)) \
{ \
throw std::runtime_error(std::string(__FILE__) + std::string(":") + std::to_string(__LINE__) + \
std::string(" in ") + std::string(__PRETTY_FUNCTION__)); \
} \
}
◆ HOPS_THROW
Value: { \
throw std::runtime_error(std::string(__FILE__) + std::string(":") + std::to_string(__LINE__) + std::string(" in ") + \
std::string(__PRETTY_FUNCTION__)); \
}
◆ REQUIRE
Value: do \
{ \
if(!(cond)) \
{ \
std::cerr << "FAIL: " #cond " @ " << __FILE__ << ":" << __LINE__ << std::endl; \
return 1; \
} \
} \
while(0)
◆ REQUIRE_CLOSE_CPLX
| #define REQUIRE_CLOSE_CPLX |
( |
|
a, |
|
|
|
b, |
|
|
|
tol |
|
) |
| |
Value: do \
{ \
if(std::abs((a) - (b)) > (tol)) \
{ \
std::cerr << "FAIL: |" #a " - " #b "| > " #tol " @ " << __FILE__ << ":" << __LINE__ \
<< " (diff=" << std::abs((a) - (b)) << ")" << std::endl; \
return 1; \
} \
} \
while(0)
◆ REQUIRE_EQUAL
| #define REQUIRE_EQUAL |
( |
|
a, |
|
|
|
b |
|
) |
| |
Value: do \
{ \
if(!((a) == (b))) \
{ \
std::stringstream _hops_sa; \
std::stringstream _hops_sb; \
_hops_sa << (a); \
_hops_sb << (b); \
std::cerr << "FAIL: " #a " == " #b " @ " << __FILE__ << ":" << __LINE__ << " (\"" << _hops_sa.str() << "\" vs \"" \
<< _hops_sb.str() << "\")" << std::endl; \
return 1; \
} \
} \
while(0)
◆ REQUIRE_THROWS
| #define REQUIRE_THROWS |
( |
|
expr | ) |
|
Value: do \
{ \
bool _hops_caught = false; \
try \
{ \
(void)(expr); \
} \
catch(const std::exception&) \
{ \
_hops_caught = true; \
} \
if(!_hops_caught) \
{ \
std::cerr << "FAIL: expected exception from " #expr " @ " << __FILE__ << ":" << __LINE__ << std::endl; \
return 1; \
} \
} \
while(0)