Files
MuditaOS/module-utils/log/tests/RandomStringGenerator.cpp
Lefucjusz 773f2c7eb1 [BH-2069] Update license URL in headers
Update outdated license file URL in
license headers across all project.
2024-09-18 11:53:01 +02:00

21 lines
669 B
C++

// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md
#include <algorithm>
#include "RandomStringGenerator.hpp"
std::string RandomStringGenerator::getRandomString()
{
const size_t length = lengthDist(rng);
std::string str(length, 0);
std::generate_n(str.begin(), length, [this]() { return charSet[charDist(rng)]; });
return str;
}
std::vector<std::string> RandomStringGenerator::createRandomStringVector(size_t size)
{
std::vector<std::string> vec(size);
std::generate_n(vec.begin(), size, [this]() { return getRandomString(); });
return vec;
}