Implement FileCollector with concurrency and stress tests
This commit is contained in:
parent
d09fb340b7
commit
4c05fe8034
26 changed files with 1745 additions and 0 deletions
27
tests/test_data.hpp
Normal file
27
tests/test_data.hpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include "file_collector/file_collector.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <random>
|
||||
|
||||
namespace test_data {
|
||||
|
||||
using namespace file_collector;
|
||||
|
||||
inline FileBytes Pattern(std::size_t size, std::uint32_t seed = 0xC0FFEE) {
|
||||
std::mt19937 rng(seed);
|
||||
FileBytes bytes(size);
|
||||
std::generate(bytes.begin(), bytes.end(), [&] { return static_cast<std::uint8_t>(rng()); });
|
||||
return bytes;
|
||||
}
|
||||
|
||||
inline FileBytes Slice(const FileBytes& data, std::size_t pos, std::size_t length) {
|
||||
return FileBytes(data.begin() + static_cast<std::ptrdiff_t>(pos),
|
||||
data.begin() + static_cast<std::ptrdiff_t>(pos + length));
|
||||
}
|
||||
|
||||
} // namespace test_data
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue