mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
refactor: Replace &foo[0] with foo.data()
This commit is contained in:
@@ -33,7 +33,7 @@ static void TestVector(const Hasher &h, const In &in, const Out &out) {
|
||||
hash.resize(out.size());
|
||||
{
|
||||
// Test that writing the whole input string at once works.
|
||||
Hasher(h).Write((unsigned char*)&in[0], in.size()).Finalize(&hash[0]);
|
||||
Hasher(h).Write((const uint8_t*)in.data(), in.size()).Finalize(hash.data());
|
||||
BOOST_CHECK(hash == out);
|
||||
}
|
||||
for (int i=0; i<32; i++) {
|
||||
@@ -42,15 +42,15 @@ static void TestVector(const Hasher &h, const In &in, const Out &out) {
|
||||
size_t pos = 0;
|
||||
while (pos < in.size()) {
|
||||
size_t len = InsecureRandRange((in.size() - pos + 1) / 2 + 1);
|
||||
hasher.Write((unsigned char*)&in[pos], len);
|
||||
hasher.Write((const uint8_t*)in.data() + pos, len);
|
||||
pos += len;
|
||||
if (pos > 0 && pos + 2 * out.size() > in.size() && pos < in.size()) {
|
||||
// Test that writing the rest at once to a copy of a hasher works.
|
||||
Hasher(hasher).Write((unsigned char*)&in[pos], in.size() - pos).Finalize(&hash[0]);
|
||||
Hasher(hasher).Write((const uint8_t*)in.data() + pos, in.size() - pos).Finalize(hash.data());
|
||||
BOOST_CHECK(hash == out);
|
||||
}
|
||||
}
|
||||
hasher.Finalize(&hash[0]);
|
||||
hasher.Finalize(hash.data());
|
||||
BOOST_CHECK(hash == out);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user