Changeset View
Changeset View
Standalone View
Standalone View
src/test/util/setup_common.h
Show First 20 Lines • Show All 195 Lines • ▼ Show 20 Lines | |||||
// define implicit conversions here so that these types may be used in | // define implicit conversions here so that these types may be used in | ||||
// BOOST_*_EQUAL | // BOOST_*_EQUAL | ||||
std::ostream &operator<<(std::ostream &os, const uint256 &num); | std::ostream &operator<<(std::ostream &os, const uint256 &num); | ||||
std::ostream &operator<<(std::ostream &os, const ScriptError &err); | std::ostream &operator<<(std::ostream &os, const ScriptError &err); | ||||
CBlock getBlock13b8a(); | CBlock getBlock13b8a(); | ||||
/** | |||||
* BOOST_CHECK_EXCEPTION predicates to check the specific validation error. | |||||
* Use as | |||||
* BOOST_CHECK_EXCEPTION(code that throws, exception type, HasReason("foo")); | |||||
*/ | |||||
class HasReason { | |||||
public: | |||||
explicit HasReason(const std::string &reason) : m_reason(reason) {} | |||||
template <typename E> bool operator()(const E &e) const { | |||||
return std::string(e.what()).find(m_reason) != std::string::npos; | |||||
}; | |||||
private: | |||||
const std::string m_reason; | |||||
}; | |||||
#endif // BITCOIN_TEST_UTIL_SETUP_COMMON_H | #endif // BITCOIN_TEST_UTIL_SETUP_COMMON_H |