10
10
#include < key.h>
11
11
#include < node/caches.h>
12
12
#include < node/context.h> // IWYU pragma: export
13
+ #include < optional>
14
+ #include < ostream>
13
15
#include < primitives/transaction.h>
14
16
#include < pubkey.h>
15
17
#include < stdexcept>
@@ -29,6 +31,8 @@ class arith_uint256;
29
31
class CFeeRate ;
30
32
class Chainstate ;
31
33
class FastRandomContext ;
34
+ class uint160 ;
35
+ class uint256 ;
32
36
33
37
/* * This is connected to the logger. Can be used to redirect logs to any other log */
34
38
extern const std::function<void (const std::string&)> G_TEST_LOG_FUN;
@@ -39,15 +43,6 @@ extern const std::function<std::vector<const char*>()> G_TEST_COMMAND_LINE_ARGUM
39
43
/* * Retrieve the unit test name. */
40
44
extern const std::function<std::string()> G_TEST_GET_FULL_NAME;
41
45
42
- // Enable BOOST_CHECK_EQUAL for enum class types
43
- namespace std {
44
- template <typename T>
45
- std::ostream& operator <<(typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream, const T& e)
46
- {
47
- return stream << static_cast <typename std::underlying_type<T>::type>(e);
48
- }
49
- } // namespace std
50
-
51
46
static constexpr CAmount CENT{1000000 };
52
47
53
48
struct TestOpts {
@@ -250,10 +245,26 @@ std::unique_ptr<T> MakeNoLogFileContext(const ChainType chain_type = ChainType::
250
245
251
246
CBlock getBlock13b8a ();
252
247
253
- // Make types usable in BOOST_CHECK_*
248
+ // Make types usable in BOOST_CHECK_* @{
249
+ namespace std {
250
+ template <typename T> requires std::is_enum_v<T>
251
+ inline std::ostream& operator <<(std::ostream& os, const T& e)
252
+ {
253
+ return os << static_cast <std::underlying_type_t <T>>(e);
254
+ }
255
+
256
+ template <typename T>
257
+ inline std::ostream& operator <<(std::ostream& os, const std::optional<T>& v)
258
+ {
259
+ return v ? os << *v
260
+ : os << " std::nullopt" ;
261
+ }
262
+ } // namespace std
263
+
254
264
std::ostream& operator <<(std::ostream& os, const arith_uint256& num);
255
265
std::ostream& operator <<(std::ostream& os, const uint160& num);
256
266
std::ostream& operator <<(std::ostream& os, const uint256& num);
267
+ // @}
257
268
258
269
/* *
259
270
* BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
0 commit comments