Bitcoin Core  31.0.0
P2P Digital Currency
util_check_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <util/check.h>
6 
7 #include <boost/test/unit_test.hpp>
8 #include <test/util/common.h>
9 
10 BOOST_AUTO_TEST_SUITE(util_check_tests)
11 
13 {
14  Assume(true);
15  Assert(true);
16  CHECK_NONFATAL(true);
17 }
18 
20 {
21  // Disable aborts for easier testing here
23 
24  if constexpr (G_ABORT_ON_FAILED_ASSUME) {
25  BOOST_CHECK_EXCEPTION(Assume(false), NonFatalCheckError, HasReason{"Internal bug detected: false"});
26  } else {
28  }
29  BOOST_CHECK_EXCEPTION(Assert(false), NonFatalCheckError, HasReason{"Internal bug detected: false"});
30  BOOST_CHECK_EXCEPTION(CHECK_NONFATAL(false), NonFatalCheckError, HasReason{"Internal bug detected: false"});
31 }
32 
constexpr bool G_ABORT_ON_FAILED_ASSUME
Definition: check.h:25
#define CHECK_NONFATAL(condition)
Identity function.
Definition: check.h:109
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
Definition: common.h:17
#define Assume(val)
Assume is the identity function.
Definition: check.h:125
#define BOOST_CHECK_NO_THROW(stmt)
Definition: object.cpp:27
#define Assert(val)
Identity function.
Definition: check.h:113
BOOST_AUTO_TEST_CASE(check_pass)