diff --git a/tests/test_many_random_payloads.cc b/tests/test_many_random_payloads.cc index 9ee434c..d3c45c6 100644 --- a/tests/test_many_random_payloads.cc +++ b/tests/test_many_random_payloads.cc @@ -9,19 +9,27 @@ #include #include +using std::atomic; +using std::generate; +using std::max; +using std::mt19937; +using std::none_of; +using std::thread; +using std::vector; + auto constexpr LEN{ 4u * 1024u * 1024u }; namespace { -std::atomic s_iterations{ 250u }; +atomic s_iterations{ 250u }; } TEST_CASE("many random payloads") { auto const thread_proc{ [](unsigned seed) { - std::mt19937 mt{ seed }; // deterministic + mt19937 mt{ seed }; // deterministic byte_vec_t src(LEN), dec(LEN), enc(COBS_ENCODE_MAX(LEN)); while (--s_iterations > 0) { - std::generate(src.begin(), src.end(), [&]() { return byte_t(mt()); }); + generate(src.begin(), src.end(), [&]() { return byte_t(mt()); }); memset(src.data() + 1000, 0xAA, 256 * 10); // nonzero run size_t enc_len{ 0u }; @@ -30,8 +38,7 @@ TEST_CASE("many random payloads") { REQUIRE(enc_len >= LEN); REQUIRE(enc_len <= COBS_ENCODE_MAX(LEN)); - REQUIRE( - std::none_of(enc.data(), enc.data() + enc_len - 1, [](byte_t b) { return !b; })); + REQUIRE(none_of(enc.data(), enc.data() + enc_len - 1, [](byte_t b) { return !b; })); REQUIRE(enc[enc_len - 1] == 0); size_t dec_len{ 0u }; @@ -43,9 +50,8 @@ TEST_CASE("many random payloads") { } } }; - std::vector threads; - for (auto i{ 0u }, n{ std::max(1u, std::thread::hardware_concurrency() - 1) }; i < n; - ++i) { + vector threads; + for (auto i{ 0u }, n{ max(1u, thread::hardware_concurrency() - 1) }; i < n; ++i) { threads.emplace_back(thread_proc, i); }