DataBlockFixture create data that is independent from its size

This commit is contained in:
Sebastian Messmer 2015-03-04 02:58:52 +01:00
parent 19e14146f4
commit 09b648317f

View File

@ -1,4 +1,4 @@
#include <messmer/blockstore/test/testutils/DataBlockFixture.h> #include "DataBlockFixture.h"
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
@ -20,11 +20,13 @@ void DataBlockFixture::fillFileWithRandomData(long long int IV) {
val += 1442695040888963407; val += 1442695040888963407;
reinterpret_cast<long long int*>(_fileData)[i] = val; reinterpret_cast<long long int*>(_fileData)[i] = val;
} }
//Fill remaining bytes uint64_t alreadyWritten = (_size/sizeof(long long int))*sizeof(long long int);
for(size_t i=(_size/sizeof(long long int))*sizeof(long long int); i<_size; ++i) {
val *= 6364136223846793005L; val *= 6364136223846793005L;
val += 1442695040888963407; val += 1442695040888963407;
reinterpret_cast<char*>(_fileData)[i] = val; char *remainingBytes = reinterpret_cast<char*>(&val);
//Fill remaining bytes
for(size_t i=0; i<_size-alreadyWritten; ++i) {
reinterpret_cast<char*>(_fileData)[alreadyWritten + i] = remainingBytes[i];
} }
} }