Bitcoin Core
31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
src
test
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
12
BOOST_AUTO_TEST_CASE
(
check_pass
)
13
{
14
Assume
(
true
);
15
Assert
(
true
);
16
CHECK_NONFATAL
(
true
);
17
}
18
19
BOOST_AUTO_TEST_CASE
(
check_fail
)
20
{
21
// Disable aborts for easier testing here
22
test_only_CheckFailuresAreExceptionsNotAborts
mock_checks
{};
23
24
if
constexpr
(
G_ABORT_ON_FAILED_ASSUME
) {
25
BOOST_CHECK_EXCEPTION
(
Assume
(
false
),
NonFatalCheckError
,
HasReason
{
"Internal bug detected: false"
});
26
}
else
{
27
BOOST_CHECK_NO_THROW
(
Assume
(
false
));
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
33
BOOST_AUTO_TEST_SUITE_END
()
check.h
CHECK_NONFATAL
#define CHECK_NONFATAL(condition)
Identity function.
Definition
check.h:109
Assert
#define Assert(val)
Identity function.
Definition
check.h:113
G_ABORT_ON_FAILED_ASSUME
constexpr bool G_ABORT_ON_FAILED_ASSUME
Definition
check.h:25
Assume
#define Assume(val)
Assume is the identity function.
Definition
check.h:125
HasReason
BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
Definition
common.h:18
NonFatalCheckError
Definition
check.h:59
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_NO_THROW
#define BOOST_CHECK_NO_THROW(stmt)
Definition
object.cpp:27
test_only_CheckFailuresAreExceptionsNotAborts
Definition
check.h:51
common.h
Ticks
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition
time.h:73
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(check_pass)
Definition
util_check_tests.cpp:12
Generated on Thu Apr 16 2026 09:42:38 for Bitcoin Core by
1.10.0