From 02ae3615fd6082946d9eb4b2223d0ec2c668db74 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Wed, 4 Mar 2015 02:59:46 +0100 Subject: [PATCH] DataBlockFixture create data that is independent from its size --- test/testutils/DataBlockFixture.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/testutils/DataBlockFixture.cpp b/test/testutils/DataBlockFixture.cpp index 52c3c6ee..252015b2 100644 --- a/test/testutils/DataBlockFixture.cpp +++ b/test/testutils/DataBlockFixture.cpp @@ -20,11 +20,13 @@ void DataBlockFixture::fillFileWithRandomData(long long int IV) { val += 1442695040888963407; reinterpret_cast(_fileData)[i] = val; } + uint64_t alreadyWritten = (_size/sizeof(long long int))*sizeof(long long int); + val *= 6364136223846793005L; + val += 1442695040888963407; + char *remainingBytes = reinterpret_cast(&val); //Fill remaining bytes - for(size_t i=(_size/sizeof(long long int))*sizeof(long long int); i<_size; ++i) { - val *= 6364136223846793005L; - val += 1442695040888963407; - reinterpret_cast(_fileData)[i] = val; + for(size_t i=0; i<_size-alreadyWritten; ++i) { + reinterpret_cast(_fileData)[alreadyWritten + i] = remainingBytes[i]; } }