Bitcoin Core  27.99.0
P2P Digital Currency
Namespaces | Macros | Enumerations | Functions | Variables
util_tests.cpp File Reference
#include <clientversion.h>
#include <hash.h>
#include <key.h>
#include <sync.h>
#include <test/util/random.h>
#include <test/util/setup_common.h>
#include <uint256.h>
#include <util/bitdeque.h>
#include <util/fs.h>
#include <util/fs_helpers.h>
#include <util/message.h>
#include <util/moneystr.h>
#include <util/overflow.h>
#include <util/readwritefile.h>
#include <util/spanparsing.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/time.h>
#include <util/vector.h>
#include <array>
#include <cmath>
#include <fstream>
#include <limits>
#include <map>
#include <optional>
#include <stdint.h>
#include <thread>
#include <univalue.h>
#include <utility>
#include <vector>
#include <sys/types.h>
#include <signal.h>
#include <sys/wait.h>
#include <boost/test/unit_test.hpp>
Include dependency graph for util_tests.cpp:

Go to the source code of this file.

Namespaces

 BCLog
 

Macros

#define B   "check_prefix"
 
#define E   "check_postfix"
 

Enumerations

enum  : char { ResSuccess = 2 , ResErrorWrite , ResErrorLock , ResUnlockSuccess }
 

Functions

std::string BCLog::LogEscapeMessage (const std::string &str)
 Belts and suspenders: make sure outgoing log messages don't contain potentially suspicious characters, such as terminal control codes. More...
 
 BOOST_AUTO_TEST_CASE (util_check)
 
 BOOST_AUTO_TEST_CASE (util_criticalsection)
 
 BOOST_AUTO_TEST_CASE (parse_hex)
 
 BOOST_AUTO_TEST_CASE (util_HexStr)
 
 BOOST_AUTO_TEST_CASE (span_write_bytes)
 
 BOOST_AUTO_TEST_CASE (util_Join)
 
 BOOST_AUTO_TEST_CASE (util_ReplaceAll)
 
 BOOST_AUTO_TEST_CASE (util_TrimString)
 
 BOOST_AUTO_TEST_CASE (util_FormatISO8601DateTime)
 
 BOOST_AUTO_TEST_CASE (util_FormatISO8601Date)
 
 BOOST_AUTO_TEST_CASE (util_FormatMoney)
 
 BOOST_AUTO_TEST_CASE (util_ParseMoney)
 
 BOOST_AUTO_TEST_CASE (util_IsHex)
 
 BOOST_AUTO_TEST_CASE (util_IsHexNumber)
 
 BOOST_AUTO_TEST_CASE (util_seed_insecure_rand)
 
 BOOST_AUTO_TEST_CASE (util_TimingResistantEqual)
 
 BOOST_AUTO_TEST_CASE (strprintf_numbers)
 
 BOOST_AUTO_TEST_CASE (gettime)
 
 BOOST_AUTO_TEST_CASE (util_time_GetTime)
 
 BOOST_AUTO_TEST_CASE (test_IsDigit)
 
template<typename T >
static void TestAddMatrixOverflow ()
 
template<typename T >
static void TestAddMatrix ()
 
 BOOST_AUTO_TEST_CASE (util_overflow)
 
 BOOST_AUTO_TEST_CASE (test_ParseInt32)
 
template<typename T >
static void RunToIntegralTests ()
 
 BOOST_AUTO_TEST_CASE (test_ToIntegral)
 
int64_t atoi64_legacy (const std::string &str)
 
 BOOST_AUTO_TEST_CASE (test_LocaleIndependentAtoi)
 
 BOOST_AUTO_TEST_CASE (test_ParseInt64)
 
 BOOST_AUTO_TEST_CASE (test_ParseUInt8)
 
 BOOST_AUTO_TEST_CASE (test_ParseUInt16)
 
 BOOST_AUTO_TEST_CASE (test_ParseUInt32)
 
 BOOST_AUTO_TEST_CASE (test_ParseUInt64)
 
 BOOST_AUTO_TEST_CASE (test_FormatParagraph)
 
 BOOST_AUTO_TEST_CASE (test_FormatSubVersion)
 
 BOOST_AUTO_TEST_CASE (test_ParseFixedPoint)
 
static void TestOtherProcess (fs::path dirname, fs::path lockname, int fd)
 
 BOOST_AUTO_TEST_CASE (test_LockDirectory)
 
 BOOST_AUTO_TEST_CASE (test_ToLower)
 
 BOOST_AUTO_TEST_CASE (test_ToUpper)
 
 BOOST_AUTO_TEST_CASE (test_Capitalize)
 
static std::string SpanToStr (const Span< const char > &span)
 
 BOOST_AUTO_TEST_CASE (test_spanparsing)
 
 BOOST_AUTO_TEST_CASE (test_SplitString)
 
 BOOST_AUTO_TEST_CASE (test_LogEscapeMessage)
 
 BOOST_AUTO_TEST_CASE (test_tracked_vector)
 
 BOOST_AUTO_TEST_CASE (message_sign)
 
 BOOST_AUTO_TEST_CASE (message_verify)
 
 BOOST_AUTO_TEST_CASE (message_hash)
 
 BOOST_AUTO_TEST_CASE (remove_prefix)
 
 BOOST_AUTO_TEST_CASE (util_ParseByteUnits)
 
 BOOST_AUTO_TEST_CASE (util_ReadBinaryFile)
 
 BOOST_AUTO_TEST_CASE (util_WriteBinaryFile)
 
 BOOST_AUTO_TEST_CASE (clearshrink_test)
 

Variables

static const std::string STRING_WITH_EMBEDDED_NULL_CHAR {"1"s "\0" "1"s}
 
static const unsigned char ParseHex_expected [65]
 
static constexpr char LockCommand = 'L'
 
static constexpr char UnlockCommand = 'U'
 
static constexpr char ExitCommand = 'X'
 

Macro Definition Documentation

◆ B

#define B   "check_prefix"

Definition at line 489 of file util_tests.cpp.

◆ E

#define E   "check_postfix"

Definition at line 490 of file util_tests.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : char
Enumerator
ResSuccess 
ResErrorWrite 
ResErrorLock 
ResUnlockSuccess 

Definition at line 1117 of file util_tests.cpp.

Function Documentation

◆ atoi64_legacy()

int64_t atoi64_legacy ( const std::string &  str)

Definition at line 739 of file util_tests.cpp.

Here is the caller graph for this function:

◆ BOOST_AUTO_TEST_CASE() [1/48]

BOOST_AUTO_TEST_CASE ( clearshrink_test  )

Definition at line 1799 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/48]

BOOST_AUTO_TEST_CASE ( gettime  )

Definition at line 517 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/48]

BOOST_AUTO_TEST_CASE ( message_hash  )

Definition at line 1675 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/48]

BOOST_AUTO_TEST_CASE ( message_sign  )

Definition at line 1587 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/48]

BOOST_AUTO_TEST_CASE ( message_verify  )

Definition at line 1623 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/48]

BOOST_AUTO_TEST_CASE ( parse_hex  )

Definition at line 137 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/48]

BOOST_AUTO_TEST_CASE ( remove_prefix  )

Definition at line 1692 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [8/48]

BOOST_AUTO_TEST_CASE ( span_write_bytes  )

Definition at line 236 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [9/48]

BOOST_AUTO_TEST_CASE ( strprintf_numbers  )

Definition at line 491 of file util_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [10/48]

BOOST_AUTO_TEST_CASE ( test_Capitalize  )

Definition at line 1283 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [11/48]

BOOST_AUTO_TEST_CASE ( test_FormatParagraph  )

Definition at line 1000 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [12/48]

BOOST_AUTO_TEST_CASE ( test_FormatSubVersion  )

Definition at line 1027 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [13/48]

BOOST_AUTO_TEST_CASE ( test_IsDigit  )

Definition at line 551 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [14/48]

BOOST_AUTO_TEST_CASE ( test_LocaleIndependentAtoi  )

Definition at line 744 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [15/48]

BOOST_AUTO_TEST_CASE ( test_LockDirectory  )

Definition at line 1159 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [16/48]

BOOST_AUTO_TEST_CASE ( test_LogEscapeMessage  )

Definition at line 1475 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [17/48]

BOOST_AUTO_TEST_CASE ( test_ParseFixedPoint  )

Definition at line 1039 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [18/48]

BOOST_AUTO_TEST_CASE ( test_ParseInt32  )

Definition at line 614 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [19/48]

BOOST_AUTO_TEST_CASE ( test_ParseInt64  )

Definition at line 835 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [20/48]

BOOST_AUTO_TEST_CASE ( test_ParseUInt16  )

Definition at line 898 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [21/48]

BOOST_AUTO_TEST_CASE ( test_ParseUInt32  )

Definition at line 933 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [22/48]

BOOST_AUTO_TEST_CASE ( test_ParseUInt64  )

Definition at line 970 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [23/48]

BOOST_AUTO_TEST_CASE ( test_ParseUInt8  )

Definition at line 863 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [24/48]

BOOST_AUTO_TEST_CASE ( test_spanparsing  )

Definition at line 1295 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [25/48]

BOOST_AUTO_TEST_CASE ( test_SplitString  )

Definition at line 1413 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [26/48]

BOOST_AUTO_TEST_CASE ( test_ToIntegral  )

Definition at line 677 of file util_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [27/48]

BOOST_AUTO_TEST_CASE ( test_ToLower  )

Definition at line 1255 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [28/48]

BOOST_AUTO_TEST_CASE ( test_ToUpper  )

Definition at line 1269 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [29/48]

BOOST_AUTO_TEST_CASE ( test_tracked_vector  )

Definition at line 1510 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [30/48]

BOOST_AUTO_TEST_CASE ( util_check  )

Definition at line 82 of file util_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [31/48]

BOOST_AUTO_TEST_CASE ( util_criticalsection  )

Definition at line 108 of file util_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [32/48]

BOOST_AUTO_TEST_CASE ( util_FormatISO8601Date  )

Definition at line 299 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [33/48]

BOOST_AUTO_TEST_CASE ( util_FormatISO8601DateTime  )

Definition at line 291 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [34/48]

BOOST_AUTO_TEST_CASE ( util_FormatMoney  )

Definition at line 307 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [35/48]

BOOST_AUTO_TEST_CASE ( util_HexStr  )

Definition at line 192 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [36/48]

BOOST_AUTO_TEST_CASE ( util_IsHex  )

Definition at line 411 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [37/48]

BOOST_AUTO_TEST_CASE ( util_IsHexNumber  )

Definition at line 426 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [38/48]

BOOST_AUTO_TEST_CASE ( util_Join  )

Definition at line 245 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [39/48]

BOOST_AUTO_TEST_CASE ( util_overflow  )

Definition at line 608 of file util_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [40/48]

BOOST_AUTO_TEST_CASE ( util_ParseByteUnits  )

Definition at line 1705 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [41/48]

BOOST_AUTO_TEST_CASE ( util_ParseMoney  )

Definition at line 342 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [42/48]

BOOST_AUTO_TEST_CASE ( util_ReadBinaryFile  )

Definition at line 1753 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [43/48]

BOOST_AUTO_TEST_CASE ( util_ReplaceAll  )

Definition at line 259 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [44/48]

BOOST_AUTO_TEST_CASE ( util_seed_insecure_rand  )

Definition at line 451 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [45/48]

BOOST_AUTO_TEST_CASE ( util_time_GetTime  )

Definition at line 522 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [46/48]

BOOST_AUTO_TEST_CASE ( util_TimingResistantEqual  )

Definition at line 476 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [47/48]

BOOST_AUTO_TEST_CASE ( util_TrimString  )

Definition at line 275 of file util_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [48/48]

BOOST_AUTO_TEST_CASE ( util_WriteBinaryFile  )

Definition at line 1786 of file util_tests.cpp.

Here is the call graph for this function:

◆ RunToIntegralTests()

template<typename T >
static void RunToIntegralTests ( )
static

Definition at line 649 of file util_tests.cpp.

◆ SpanToStr()

static std::string SpanToStr ( const Span< const char > &  span)
static

Definition at line 1290 of file util_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestAddMatrix()

template<typename T >
static void TestAddMatrix ( )
static

Definition at line 588 of file util_tests.cpp.

Here is the call graph for this function:

◆ TestAddMatrixOverflow()

template<typename T >
static void TestAddMatrixOverflow ( )
static

Definition at line 568 of file util_tests.cpp.

Here is the call graph for this function:

◆ TestOtherProcess()

static void TestOtherProcess ( fs::path  dirname,
fs::path  lockname,
int  fd 
)
static

Definition at line 1124 of file util_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ExitCommand

constexpr char ExitCommand = 'X'
staticconstexpr

Definition at line 1116 of file util_tests.cpp.

◆ LockCommand

constexpr char LockCommand = 'L'
staticconstexpr

Definition at line 1114 of file util_tests.cpp.

◆ ParseHex_expected

const unsigned char ParseHex_expected[65]
static
Initial value:
= {
0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7,
0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde,
0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12,
0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d,
0x5f
}

Definition at line 130 of file util_tests.cpp.

◆ STRING_WITH_EMBEDDED_NULL_CHAR

const std::string STRING_WITH_EMBEDDED_NULL_CHAR {"1"s "\0" "1"s}
static

Definition at line 48 of file util_tests.cpp.

◆ UnlockCommand

constexpr char UnlockCommand = 'U'
staticconstexpr

Definition at line 1115 of file util_tests.cpp.