diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/checkqueue_tests.cpp | 4 | ||||
-rw-r--r-- | src/test/crypto_tests.cpp | 4 | ||||
-rw-r--r-- | src/test/fuzz/p2p_transport_serialization.cpp | 2 | ||||
-rw-r--r-- | src/test/fuzz/versionbits.cpp | 2 | ||||
-rw-r--r-- | src/test/merkle_tests.cpp | 10 | ||||
-rw-r--r-- | src/test/random_tests.cpp | 2 | ||||
-rw-r--r-- | src/test/serialize_tests.cpp | 12 | ||||
-rw-r--r-- | src/test/streams_tests.cpp | 4 | ||||
-rw-r--r-- | src/test/util_tests.cpp | 8 | ||||
-rw-r--r-- | src/test/validation_chainstate_tests.cpp | 2 | ||||
-rw-r--r-- | src/test/validation_flush_tests.cpp | 2 |
11 files changed, 26 insertions, 26 deletions
diff --git a/src/test/checkqueue_tests.cpp b/src/test/checkqueue_tests.cpp index faf6055b67..53fbc26e15 100644 --- a/src/test/checkqueue_tests.cpp +++ b/src/test/checkqueue_tests.cpp @@ -194,7 +194,7 @@ static void Correct_Queue_range(std::vector<size_t> range) BOOST_AUTO_TEST_CASE(test_CheckQueue_Correct_Zero) { std::vector<size_t> range; - range.push_back((size_t)0); + range.push_back(size_t{0}); Correct_Queue_range(range); } /** Test that 1 check is correct @@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Correct_Zero) BOOST_AUTO_TEST_CASE(test_CheckQueue_Correct_One) { std::vector<size_t> range; - range.push_back((size_t)1); + range.push_back(size_t{1}); Correct_Queue_range(range); } /** Test that MAX check is correct diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp index 6148edf115..9b369a5c50 100644 --- a/src/test/crypto_tests.cpp +++ b/src/test/crypto_tests.cpp @@ -723,14 +723,14 @@ BOOST_AUTO_TEST_CASE(countbits_tests) // Check handling of zero. BOOST_CHECK_EQUAL(CountBits(0), 0U); } else if (i < 10) { - for (uint64_t j = (uint64_t)1 << (i - 1); (j >> i) == 0; ++j) { + for (uint64_t j = uint64_t{1} << (i - 1); (j >> i) == 0; ++j) { // Exhaustively test up to 10 bits BOOST_CHECK_EQUAL(CountBits(j), i); } } else { for (int k = 0; k < 1000; k++) { // Randomly test 1000 samples of each length above 10 bits. - uint64_t j = ((uint64_t)1) << (i - 1) | ctx.randbits(i - 1); + uint64_t j = (uint64_t{1}) << (i - 1) | ctx.randbits(i - 1); BOOST_CHECK_EQUAL(CountBits(j), i); } } diff --git a/src/test/fuzz/p2p_transport_serialization.cpp b/src/test/fuzz/p2p_transport_serialization.cpp index 3eb370a858..96254aa222 100644 --- a/src/test/fuzz/p2p_transport_serialization.cpp +++ b/src/test/fuzz/p2p_transport_serialization.cpp @@ -24,7 +24,7 @@ void initialize_p2p_transport_serialization() FUZZ_TARGET_INIT(p2p_transport_serialization, initialize_p2p_transport_serialization) { // Construct deserializer, with a dummy NodeId - V1TransportDeserializer deserializer{Params(), (NodeId)0, SER_NETWORK, INIT_PROTO_VERSION}; + V1TransportDeserializer deserializer{Params(), NodeId{0}, SER_NETWORK, INIT_PROTO_VERSION}; V1TransportSerializer serializer{}; FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; diff --git a/src/test/fuzz/versionbits.cpp b/src/test/fuzz/versionbits.cpp index 95eb71099d..143027662f 100644 --- a/src/test/fuzz/versionbits.cpp +++ b/src/test/fuzz/versionbits.cpp @@ -55,7 +55,7 @@ public: bool Condition(int32_t version) const { - uint32_t mask = ((uint32_t)1) << m_bit; + uint32_t mask = (uint32_t{1}) << m_bit; return (((version & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (version & mask) != 0); } diff --git a/src/test/merkle_tests.cpp b/src/test/merkle_tests.cpp index 942d54ede8..bba103d1b0 100644 --- a/src/test/merkle_tests.cpp +++ b/src/test/merkle_tests.cpp @@ -50,7 +50,7 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot // For each of the lower bits in count that are 0, do 1 step. Each // corresponds to an inner value that existed before processing the // current leaf, and each needs a hash to combine it. - for (level = 0; !(count & (((uint32_t)1) << level)); level++) { + for (level = 0; !(count & ((uint32_t{1}) << level)); level++) { if (pbranch) { if (matchh) { pbranch->push_back(inner[level]); @@ -74,12 +74,12 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot int level = 0; // As long as bit number level in count is zero, skip it. It means there // is nothing left at this level. - while (!(count & (((uint32_t)1) << level))) { + while (!(count & ((uint32_t{1}) << level))) { level++; } uint256 h = inner[level]; bool matchh = matchlevel == level; - while (count != (((uint32_t)1) << level)) { + while (count != ((uint32_t{1}) << level)) { // If we reach this point, h is an inner value that is not the top. // We combine it with itself (Bitcoin's special rule for odd levels in // the tree) to produce a higher level one. @@ -89,10 +89,10 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot CHash256().Write(h).Write(h).Finalize(h); // Increment count to the value it would have if two entries at this // level had existed. - count += (((uint32_t)1) << level); + count += ((uint32_t{1}) << level); level++; // And propagate the result upwards accordingly. - while (!(count & (((uint32_t)1) << level))) { + while (!(count & ((uint32_t{1}) << level))) { if (pbranch) { if (matchh) { pbranch->push_back(inner[level]); diff --git a/src/test/random_tests.cpp b/src/test/random_tests.cpp index 54d5ab6794..db659af0b8 100644 --- a/src/test/random_tests.cpp +++ b/src/test/random_tests.cpp @@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(fastrandom_randbits) for (int j = 0; j < 1000; ++j) { uint64_t rangebits = ctx1.randbits(bits); BOOST_CHECK_EQUAL(rangebits >> bits, 0U); - uint64_t range = ((uint64_t)1) << bits | rangebits; + uint64_t range = (uint64_t{1}) << bits | rangebits; uint64_t rand = ctx2.randrange(range); BOOST_CHECK(rand < range); } diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index 5f8e353dd6..c90ae38ae8 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -123,17 +123,17 @@ BOOST_AUTO_TEST_CASE(varints_bitpatterns) CDataStream ss(SER_DISK, 0); ss << VARINT_MODE(0, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "00"); ss.clear(); ss << VARINT_MODE(0x7f, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "7f"); ss.clear(); - ss << VARINT_MODE((int8_t)0x7f, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "7f"); ss.clear(); + ss << VARINT_MODE(int8_t{0x7f}, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "7f"); ss.clear(); ss << VARINT_MODE(0x80, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "8000"); ss.clear(); - ss << VARINT((uint8_t)0x80); BOOST_CHECK_EQUAL(HexStr(ss), "8000"); ss.clear(); + ss << VARINT(uint8_t{0x80}); BOOST_CHECK_EQUAL(HexStr(ss), "8000"); ss.clear(); ss << VARINT_MODE(0x1234, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "a334"); ss.clear(); - ss << VARINT_MODE((int16_t)0x1234, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "a334"); ss.clear(); + ss << VARINT_MODE(int16_t{0x1234}, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "a334"); ss.clear(); ss << VARINT_MODE(0xffff, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "82fe7f"); ss.clear(); - ss << VARINT((uint16_t)0xffff); BOOST_CHECK_EQUAL(HexStr(ss), "82fe7f"); ss.clear(); + ss << VARINT(uint16_t{0xffff}); BOOST_CHECK_EQUAL(HexStr(ss), "82fe7f"); ss.clear(); ss << VARINT_MODE(0x123456, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "c7e756"); ss.clear(); - ss << VARINT_MODE((int32_t)0x123456, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "c7e756"); ss.clear(); + ss << VARINT_MODE(int32_t{0x123456}, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "c7e756"); ss.clear(); ss << VARINT(0x80123456U); BOOST_CHECK_EQUAL(HexStr(ss), "86ffc7e756"); ss.clear(); - ss << VARINT((uint32_t)0x80123456U); BOOST_CHECK_EQUAL(HexStr(ss), "86ffc7e756"); ss.clear(); + ss << VARINT(uint32_t{0x80123456U}); BOOST_CHECK_EQUAL(HexStr(ss), "86ffc7e756"); ss.clear(); ss << VARINT(0xffffffff); BOOST_CHECK_EQUAL(HexStr(ss), "8efefefe7f"); ss.clear(); ss << VARINT_MODE(0x7fffffffffffffffLL, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "fefefefefefefefe7f"); ss.clear(); ss << VARINT(0xffffffffffffffffULL); BOOST_CHECK_EQUAL(HexStr(ss), "80fefefefefefefefe7f"); ss.clear(); diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp index c4be3a4129..dce230ac10 100644 --- a/src/test/streams_tests.cpp +++ b/src/test/streams_tests.cpp @@ -144,10 +144,10 @@ BOOST_AUTO_TEST_CASE(bitstream_reader_writer) CDataStream data_copy(data); uint32_t serialized_int1; data >> serialized_int1; - BOOST_CHECK_EQUAL(serialized_int1, (uint32_t)0x7700C35A); // NOTE: Serialized as LE + BOOST_CHECK_EQUAL(serialized_int1, uint32_t{0x7700C35A}); // NOTE: Serialized as LE uint16_t serialized_int2; data >> serialized_int2; - BOOST_CHECK_EQUAL(serialized_int2, (uint16_t)0x1072); // NOTE: Serialized as LE + BOOST_CHECK_EQUAL(serialized_int2, uint16_t{0x1072}); // NOTE: Serialized as LE BitStreamReader<CDataStream> bit_reader(data_copy); BOOST_CHECK_EQUAL(bit_reader.Read(1), 0U); diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 4d04c076e3..6b6bb18523 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -810,8 +810,8 @@ BOOST_AUTO_TEST_CASE(test_ParseInt64) BOOST_CHECK(ParseInt64("01234", &n) && n == 1234LL); // no octal BOOST_CHECK(ParseInt64("2147483647", &n) && n == 2147483647LL); BOOST_CHECK(ParseInt64("-2147483648", &n) && n == -2147483648LL); - BOOST_CHECK(ParseInt64("9223372036854775807", &n) && n == (int64_t)9223372036854775807); - BOOST_CHECK(ParseInt64("-9223372036854775808", &n) && n == (int64_t)-9223372036854775807-1); + BOOST_CHECK(ParseInt64("9223372036854775807", &n) && n == int64_t{9223372036854775807}); + BOOST_CHECK(ParseInt64("-9223372036854775808", &n) && n == int64_t{-9223372036854775807-1}); BOOST_CHECK(ParseInt64("-1234", &n) && n == -1234LL); // Invalid values BOOST_CHECK(!ParseInt64("", &n)); @@ -907,8 +907,8 @@ BOOST_AUTO_TEST_CASE(test_ParseUInt32) BOOST_CHECK(ParseUInt32("1234", &n) && n == 1234); BOOST_CHECK(ParseUInt32("01234", &n) && n == 1234); // no octal BOOST_CHECK(ParseUInt32("2147483647", &n) && n == 2147483647); - BOOST_CHECK(ParseUInt32("2147483648", &n) && n == (uint32_t)2147483648); - BOOST_CHECK(ParseUInt32("4294967295", &n) && n == (uint32_t)4294967295); + BOOST_CHECK(ParseUInt32("2147483648", &n) && n == uint32_t{2147483648}); + BOOST_CHECK(ParseUInt32("4294967295", &n) && n == uint32_t{4294967295}); BOOST_CHECK(ParseUInt32("+1234", &n) && n == 1234); BOOST_CHECK(ParseUInt32("00000000000000001234", &n) && n == 1234); BOOST_CHECK(ParseUInt32("00000000000000000000", &n) && n == 0); diff --git a/src/test/validation_chainstate_tests.cpp b/src/test/validation_chainstate_tests.cpp index c0d59d6136..c40481a95c 100644 --- a/src/test/validation_chainstate_tests.cpp +++ b/src/test/validation_chainstate_tests.cpp @@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches) COutPoint outp{txid, 0}; newcoin.nHeight = 1; newcoin.out.nValue = InsecureRand32(); - newcoin.out.scriptPubKey.assign((uint32_t)56, 1); + newcoin.out.scriptPubKey.assign(uint32_t{56}, 1); coins_view.AddCoin(outp, std::move(newcoin), false); return outp; diff --git a/src/test/validation_flush_tests.cpp b/src/test/validation_flush_tests.cpp index a006d715cc..f2ff570ca6 100644 --- a/src/test/validation_flush_tests.cpp +++ b/src/test/validation_flush_tests.cpp @@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate) COutPoint outp{txid, 0}; newcoin.nHeight = 1; newcoin.out.nValue = InsecureRand32(); - newcoin.out.scriptPubKey.assign((uint32_t)56, 1); + newcoin.out.scriptPubKey.assign(uint32_t{56}, 1); coins_view.AddCoin(outp, std::move(newcoin), false); return outp; |