* @brief Generates a random string of a given size from a given set of characters. * @param size Size of the string to generate. * @param chrs Set of characters to use for the string. * @return A random string of the given size. */
| 176 | * @return A random string of the given size. |
| 177 | */ |
| 178 | inline std::string random_string(int size, |
| 179 | const std::string_view chrs = "0123456789" |
| 180 | "abcdefghijklmnopqrstuvwxyz" |
| 181 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ") |
| 182 | { |
| 183 | auto& rg = random_engine(); |
| 184 | std::uniform_int_distribution<std::string::size_type> pick(0, chrs.size()-1); |
| 185 | std::string s; |
| 186 | s.reserve(size); |
| 187 | while(size--) { |
| 188 | s += chrs[pick(rg)]; |
| 189 | } |
| 190 | return s; |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * @brief Uses the random_string function to generate a random uuid-formatted string. Not a true uuid, but random enough |
no test coverage detected