From 2ea2cf8b57c18a29d9af6c8e1e29863abeb76448 Mon Sep 17 00:00:00 2001 From: Victor Vazquez Date: Mon, 21 Jun 2021 11:34:59 -0700 Subject: [PATCH] updates from review (#2465) * updates from review * cast * use U for unsigned int --- sdk/core/perf/src/random_stream.cpp | 10 ++++++---- sdk/core/perf/test/src/random_stream_test.cpp | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sdk/core/perf/src/random_stream.cpp b/sdk/core/perf/src/random_stream.cpp index cea0b9d87..a32e3ec58 100644 --- a/sdk/core/perf/src/random_stream.cpp +++ b/sdk/core/perf/src/random_stream.cpp @@ -20,7 +20,7 @@ namespace { static uint8_t RandomChar() { - const uint8_t charset[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + static const uint8_t charset[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; std::uniform_int_distribution distribution(0, sizeof(charset) - 2); return charset[distribution(random_generator)]; } @@ -48,13 +48,15 @@ void RandomBuffer(uint8_t* buffer, size_t length) } } +static constexpr size_t DefaultRandomStreamBufferSize = 1024 * 1024; + } // namespace Azure::Perf::RandomStream::CircularStream::CircularStream(size_t size) - : m_buffer(std::make_unique>(1024 * 1024)), m_length(size), - m_memoryStream(*m_buffer) + : m_buffer(std::make_unique>(DefaultRandomStreamBufferSize)), + m_length(size), m_memoryStream(*m_buffer) { - RandomBuffer(m_buffer->data(), 1024 * 1024); + RandomBuffer(m_buffer->data(), DefaultRandomStreamBufferSize); } size_t Azure::Perf::RandomStream::CircularStream::OnRead( diff --git a/sdk/core/perf/test/src/random_stream_test.cpp b/sdk/core/perf/test/src/random_stream_test.cpp index 6b797431b..1ce170c8c 100644 --- a/sdk/core/perf/test/src/random_stream_test.cpp +++ b/sdk/core/perf/test/src/random_stream_test.cpp @@ -35,7 +35,7 @@ TEST(circular_stream, basic) // 4nd read count = r_stream->Read(buffer, chunk, Azure::Core::Context::ApplicationContext); - EXPECT_EQ(count, 0); + EXPECT_EQ(count, 0U); // should not change buffer for (size_t i = 0; i != chunk; i++) {