Helper to generate random string
| 2097 | |
| 2098 | // Helper to generate random string |
| 2099 | static std::string random_string(std::mt19937 & rng, size_t max_len) { |
| 2100 | static const char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; |
| 2101 | std::uniform_int_distribution<size_t> len_dist(0, max_len); |
| 2102 | std::uniform_int_distribution<size_t> char_dist(0, sizeof(charset) - 2); |
| 2103 | size_t len = len_dist(rng); |
| 2104 | std::string result; |
| 2105 | result.reserve(len); |
| 2106 | for (size_t i = 0; i < len; ++i) { |
| 2107 | result += charset[char_dist(rng)]; |
| 2108 | } |
| 2109 | return result; |
| 2110 | } |
| 2111 | |
| 2112 | // Helper to execute a fuzz test case - returns true if no crash occurred |
| 2113 | static bool fuzz_test_template(const std::string & tmpl, const json & vars) { |