diff options
author | Aurèle Oulès <aurele@oules.com> | 2022-07-26 11:12:53 +0200 |
---|---|---|
committer | Aurèle Oulès <aurele@oules.com> | 2022-07-27 13:27:57 +0200 |
commit | 081b0e53e3adca7ea57d23e5fcd9db4b86415a72 (patch) | |
tree | 877f1eb2d246084e645f8cf5961d5541438a308b /src/test | |
parent | 7f79746bf046d0028bb68f265804b9774dec2acb (diff) |
refactor: Make const refs vars where applicable
This avoids initializing variables with the copy-constructor of a
non-trivially copyable type.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/base58_tests.cpp | 4 | ||||
-rw-r--r-- | src/test/blockfilter_tests.cpp | 2 | ||||
-rw-r--r-- | src/test/key_io_tests.cpp | 6 | ||||
-rw-r--r-- | src/test/script_tests.cpp | 2 | ||||
-rw-r--r-- | src/test/sighash_tests.cpp | 2 | ||||
-rw-r--r-- | src/test/transaction_tests.cpp | 8 | ||||
-rw-r--r-- | src/test/validation_block_tests.cpp | 2 |
7 files changed, 13 insertions, 13 deletions
diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp index 00f32ddcee..249f89ae2f 100644 --- a/src/test/base58_tests.cpp +++ b/src/test/base58_tests.cpp @@ -25,7 +25,7 @@ BOOST_AUTO_TEST_CASE(base58_EncodeBase58) { UniValue tests = read_json(std::string(json_tests::base58_encode_decode, json_tests::base58_encode_decode + sizeof(json_tests::base58_encode_decode))); for (unsigned int idx = 0; idx < tests.size(); idx++) { - UniValue test = tests[idx]; + const UniValue& test = tests[idx]; std::string strTest = test.write(); if (test.size() < 2) // Allow for extra stuff (useful for comments) { @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(base58_DecodeBase58) std::vector<unsigned char> result; for (unsigned int idx = 0; idx < tests.size(); idx++) { - UniValue test = tests[idx]; + const UniValue& test = tests[idx]; std::string strTest = test.write(); if (test.size() < 2) // Allow for extra stuff (useful for comments) { diff --git a/src/test/blockfilter_tests.cpp b/src/test/blockfilter_tests.cpp index 178757e7b4..0831188327 100644 --- a/src/test/blockfilter_tests.cpp +++ b/src/test/blockfilter_tests.cpp @@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE(blockfilters_json_test) const UniValue& tests = json.get_array(); for (unsigned int i = 0; i < tests.size(); i++) { - UniValue test = tests[i]; + const UniValue& test = tests[i]; std::string strTest = test.write(); if (test.size() == 1) { diff --git a/src/test/key_io_tests.cpp b/src/test/key_io_tests.cpp index e70b8b3dfd..1eac68de14 100644 --- a/src/test/key_io_tests.cpp +++ b/src/test/key_io_tests.cpp @@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE(key_io_valid_parse) SelectParams(CBaseChainParams::MAIN); for (unsigned int idx = 0; idx < tests.size(); idx++) { - UniValue test = tests[idx]; + const UniValue& test = tests[idx]; std::string strTest = test.write(); if (test.size() < 3) { // Allow for extra stuff (useful for comments) BOOST_ERROR("Bad test: " << strTest); @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(key_io_valid_gen) UniValue tests = read_json(std::string(json_tests::key_io_valid, json_tests::key_io_valid + sizeof(json_tests::key_io_valid))); for (unsigned int idx = 0; idx < tests.size(); idx++) { - UniValue test = tests[idx]; + const UniValue& test = tests[idx]; std::string strTest = test.write(); if (test.size() < 3) // Allow for extra stuff (useful for comments) { @@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(key_io_invalid) CTxDestination destination; for (unsigned int idx = 0; idx < tests.size(); idx++) { - UniValue test = tests[idx]; + const UniValue& test = tests[idx]; std::string strTest = test.write(); if (test.size() < 1) // Allow for extra stuff (useful for comments) { diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 9e7a376d6b..935194057c 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -942,7 +942,7 @@ BOOST_AUTO_TEST_CASE(script_json_test) UniValue tests = read_json(std::string(json_tests::script_tests, json_tests::script_tests + sizeof(json_tests::script_tests))); for (unsigned int idx = 0; idx < tests.size(); idx++) { - UniValue test = tests[idx]; + const UniValue& test = tests[idx]; std::string strTest = test.write(); CScriptWitness witness; CAmount nValue = 0; diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp index 7376f2ff5c..514798d8fa 100644 --- a/src/test/sighash_tests.cpp +++ b/src/test/sighash_tests.cpp @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(sighash_from_data) UniValue tests = read_json(std::string(json_tests::sighash, json_tests::sighash + sizeof(json_tests::sighash))); for (unsigned int idx = 0; idx < tests.size(); idx++) { - UniValue test = tests[idx]; + const UniValue& test = tests[idx]; std::string strTest = test.write(); if (test.size() < 1) // Allow for extra stuff (useful for comments) { diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 4e6c223ccc..5bdf955e40 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -191,7 +191,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) UniValue tests = read_json(std::string(json_tests::tx_valid, json_tests::tx_valid + sizeof(json_tests::tx_valid))); for (unsigned int idx = 0; idx < tests.size(); idx++) { - UniValue test = tests[idx]; + const UniValue& test = tests[idx]; std::string strTest = test.write(); if (test[0].isArray()) { @@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) fValid = false; break; } - UniValue vinput = input.get_array(); + const UniValue& vinput = input.get_array(); if (vinput.size() < 3 || vinput.size() > 4) { fValid = false; @@ -279,7 +279,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid) UniValue tests = read_json(std::string(json_tests::tx_invalid, json_tests::tx_invalid + sizeof(json_tests::tx_invalid))); for (unsigned int idx = 0; idx < tests.size(); idx++) { - UniValue test = tests[idx]; + const UniValue& test = tests[idx]; std::string strTest = test.write(); if (test[0].isArray()) { @@ -299,7 +299,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid) fValid = false; break; } - UniValue vinput = input.get_array(); + const UniValue& vinput = input.get_array(); if (vinput.size() < 3 || vinput.size() > 4) { fValid = false; diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp index 7ade4d8195..78296450be 100644 --- a/src/test/validation_block_tests.cpp +++ b/src/test/validation_block_tests.cpp @@ -183,7 +183,7 @@ BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering) } // to make sure that eventually we process the full chain - do it here - for (auto block : blocks) { + for (const auto& block : blocks) { if (block->vtx.size() == 1) { bool processed = Assert(m_node.chainman)->ProcessNewBlock(block, true, &ignored); assert(processed); |