From 40451e762cb909012161e2f075a3de6f720efcb5 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Sat, 25 Apr 2015 13:20:26 +0200 Subject: [PATCH] Started replacing DataBlockFixture with DataFixture. Step 1: Create DataFixture --- data/DataFixture.cpp | 23 +++++++++++++++++++++++ data/DataFixture.h | 16 ++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 data/DataFixture.cpp create mode 100644 data/DataFixture.h diff --git a/data/DataFixture.cpp b/data/DataFixture.cpp new file mode 100644 index 00000000..b9918846 --- /dev/null +++ b/data/DataFixture.cpp @@ -0,0 +1,23 @@ +#include "DataFixture.h" + +namespace cpputils { + Data DataFixture::generate(size_t size, long long int seed) { + Data result(size); + long long int val = seed; + for(size_t i=0; i(result.data())[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=0; i(result.data())[alreadyWritten + i] = remainingBytes[i]; + } + return result; + } +} diff --git a/data/DataFixture.h b/data/DataFixture.h new file mode 100644 index 00000000..bab9bbc6 --- /dev/null +++ b/data/DataFixture.h @@ -0,0 +1,16 @@ +#pragma once +#ifndef MESSMER_CPP_UTILS_DATA_DATAFIXTURE_H_ +#define MESSMER_CPP_UTILS_DATA_DATAFIXTURE_H_ + +#include "Data.h" + +namespace cpputils { + +class DataFixture { +public: + static Data generate(size_t size, long long int seed = 1); +}; + +} + +#endif