From c288466b2adb154938228ca30882f95dcbb8594e Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Sun, 22 Nov 2020 15:21:22 +0100 Subject: [PATCH] Improve speed of unit test --- test/dwarfs.cpp | 2 +- test/loremipsum.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/dwarfs.cpp b/test/dwarfs.cpp index 0106c750..c5736475 100644 --- a/test/dwarfs.cpp +++ b/test/dwarfs.cpp @@ -177,7 +177,7 @@ void basic_end_to_end_test(const std::string& compressor, std::ostringstream logss; stream_logger lgr(logss); // TODO: mock - lgr.set_policy(); + lgr.set_policy(); scanner s(lgr, wg, cfg, entry_factory::create(no_owner, no_time, diff --git a/test/loremipsum.cpp b/test/loremipsum.cpp index 1076510c..ee0789a2 100644 --- a/test/loremipsum.cpp +++ b/test/loremipsum.cpp @@ -416,10 +416,11 @@ const std::string& loremipsum() { return s_loremipsum; } std::string loremipsum(size_t size) { std::string str; - while (str.size() < size) { + str.reserve(size); + while (str.size() + s_loremipsum.size() <= size) { str += s_loremipsum; } - str.resize(size); + str.append(s_loremipsum.data(), size - str.size()); return str; } } // namespace test