1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include "random_utf32.h"
#include <stdexcept>
#include <vector>
namespace simdutf {
namespace tests {
namespace helpers {
std::vector<char32_t> random_utf32::generate(size_t size) {
std::vector<char32_t> result;
result.reserve(size);
size_t count{0};
for (; count < size; count++) {
const uint32_t value = generate();
result.push_back(value);
}
return result;
}
std::vector<char32_t> random_utf32::generate(size_t size, long seed) {
gen.seed(seed);
return generate(size);
}
uint32_t random_utf32::generate() {
switch (range(gen)) {
case 0:
return first_range(gen);
case 1:
return second_range(gen);
default:
abort();
}
}
} // namespace helpers
} // namespace tests
} // namespace simdutf
|