Fix test cases for newer GCC versions in Release mode

This commit is contained in:
Sebastian Messmer 2021-01-12 22:09:33 -08:00
parent c751f432a6
commit caf0b90325
2 changed files with 9 additions and 9 deletions

View File

@ -2,22 +2,22 @@
#include "SerializationHelper.h"
namespace cpputils {
Data DataFixture::generate(size_t size, long long int seed) {
Data DataFixture::generate(size_t size, unsigned long long int seed) {
Data result(size);
long long int val = seed;
for(size_t i=0; i<size/sizeof(long long int); ++i) {
unsigned long long int val = seed;
for(size_t i=0; i<size/sizeof(unsigned long long int); ++i) {
//MMIX linear congruential generator
val *= 6364136223846793005L;
val += 1442695040888963407;
serialize<long long int>(result.dataOffset(i*sizeof(long long int)), val);
serialize<unsigned long long int>(result.dataOffset(i*sizeof(unsigned long long int)), val);
}
uint64_t alreadyWritten = (size/sizeof(long long int))*sizeof(long long int);
uint64_t alreadyWritten = (size/sizeof(unsigned long long int))*sizeof(unsigned long long int);
val *= 6364136223846793005L;
val += 1442695040888963407;
char *remainingBytes = reinterpret_cast<char*>(&val);
unsigned char *remainingBytes = reinterpret_cast<unsigned char*>(&val);
//Fill remaining bytes
for(size_t i=0; i<size-alreadyWritten; ++i) {
serialize<char>(result.dataOffset(alreadyWritten + i), remainingBytes[i]);
for(size_t i=0; i<sizeof(unsigned long long int); ++i) {
serialize<unsigned char>(result.dataOffset(alreadyWritten + i), remainingBytes[i]);
}
return result;
}

View File

@ -9,7 +9,7 @@ namespace cpputils {
class DataFixture final {
public:
static Data generate(size_t size, long long int seed = 1);
static Data generate(size_t size, unsigned long long int seed = 1);
//TODO Test
template<size_t SIZE> static FixedSizeData<SIZE> generateFixedSize(long long int seed = 1);