From 277be6dd08633dbebfda93afdfc6b5cb57e053e0 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 8 Apr 2024 13:18:22 +0200 Subject: Use properly included standard library types by default --- test/utils/large_objects/large_object_utils.cpp | 33 +++++++++++++------------ 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'test/utils/large_objects/large_object_utils.cpp') diff --git a/test/utils/large_objects/large_object_utils.cpp b/test/utils/large_objects/large_object_utils.cpp index b7bcebdc..6c3000ff 100644 --- a/test/utils/large_objects/large_object_utils.cpp +++ b/test/utils/large_objects/large_object_utils.cpp @@ -15,6 +15,7 @@ #include "test/utils/large_objects/large_object_utils.hpp" #include +#include #include #include #include @@ -29,7 +30,7 @@ class Randomizer final { Randomizer(std::uint64_t min, std::uint64_t max) noexcept : range_(std::random_device{}()), distribution_(min, max) {} - [[nodiscard]] inline auto Get() noexcept -> uint64_t { + [[nodiscard]] inline auto Get() noexcept -> std::uint64_t { return distribution_(range_); } @@ -41,7 +42,7 @@ class Randomizer final { /// \brief Create a number of chunks of the predefined size. /// \tparam UChunkLength Length of each chunk. /// \tparam USize Number of chunks. -template +template class ChunkPool final { public: [[nodiscard]] static auto Instance() noexcept @@ -50,7 +51,7 @@ class ChunkPool final { return pool; } - [[nodiscard]] auto operator[](size_t index) const noexcept + [[nodiscard]] auto operator[](std::size_t index) const noexcept -> std::string const& { return gsl::at(pool_, static_cast(index)); } @@ -62,10 +63,10 @@ class ChunkPool final { // Starts from 1 to exclude '\0' from randomization Randomizer randomizer{1, std::numeric_limits::max()}; - for (size_t i = 0; i < pool_.size(); ++i) { + for (std::size_t i = 0; i < pool_.size(); ++i) { auto& chunk = gsl::at(pool_, static_cast(i)); chunk.resize(kChunkLength); - for (size_t j = 0; j < kChunkLength; ++j) { + for (std::size_t j = 0; j < kChunkLength; ++j) { chunk[j] = randomizer.Get(); } } @@ -80,22 +81,22 @@ auto LargeObjectUtils::GenerateFile(std::filesystem::path const& path, return false; } - static constexpr size_t kChunkLength = 128; - static constexpr size_t kPoolSize = 64; + static constexpr std::size_t kChunkLength = 128; + static constexpr std::size_t kPoolSize = 64; using Pool = ChunkPool; // To create a random file, the initial chunk position and the shift are // randomized: - Randomizer randomizer{std::numeric_limits::min(), - std::numeric_limits::max()}; - const size_t pool_index = randomizer.Get() % kPoolSize; - const size_t pool_shift = randomizer.Get() % 10; - const size_t step_count = size / kChunkLength + 1; + Randomizer randomizer{std::numeric_limits::min(), + std::numeric_limits::max()}; + const std::size_t pool_index = randomizer.Get() % kPoolSize; + const std::size_t pool_shift = randomizer.Get() % 10; + const std::size_t step_count = size / kChunkLength + 1; try { std::ofstream stream(path); - for (size_t i = 0; i < step_count && stream.good(); ++i) { - const size_t index = (pool_index + i * pool_shift) % kPoolSize; + for (std::size_t i = 0; i < step_count && stream.good(); ++i) { + const std::size_t index = (pool_index + i * pool_shift) % kPoolSize; if (i != step_count - 1) { stream << Pool::Instance()[index]; } @@ -123,8 +124,8 @@ auto LargeObjectUtils::GenerateDirectory(std::filesystem::path const& path, return false; } - Randomizer randomizer{std::numeric_limits::min(), - std::numeric_limits::max()}; + Randomizer randomizer{std::numeric_limits::min(), + std::numeric_limits::max()}; std::uintmax_t entries = 0; while (entries < entries_count) { -- cgit v1.2.3