Skip to content

Commit 91b1720

Browse files
committed
fix: follow-up backport#19845 - fix compilation error for C++20
- fe42411 test: move HasReason so it can be reused
1 parent 7d3899f commit 91b1720

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/test/util/setup_common.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,16 @@ struct TestMemPoolEntryHelper
181181

182182
CBlock getBlock13b8a();
183183

184-
// BOOST_CHECK_EXCEPTION predicates to check the specific validation error
184+
/**
185+
* BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
186+
* Use as
187+
* BOOST_CHECK_EXCEPTION(code that throws, exception type, HasReason("foo"));
188+
*/
185189
class HasReason {
186190
public:
187191
explicit HasReason(const std::string& reason) : m_reason(reason) {}
188-
bool operator() (const std::runtime_error& e) const {
192+
template <typename E>
193+
bool operator() (const E& e) const {
189194
return std::string(e.what()).find(m_reason) != std::string::npos;
190195
};
191196
private:

0 commit comments

Comments
 (0)