##// END OF EJS Templates
Updates model after an event has been created through the colored zone
Updates model after an event has been created through the colored zone

File last commit:

r1211:08e858e2cf84
r1262:99c1ba5e139b
Show More
FuzzingUtils.h
41 lines | 1.1 KiB | text/x-c | CLexer
Alexandre Leroux
Adds utility class to get random values
r1206 #ifndef SCIQLOP_FUZZINGUTILS_H
#define SCIQLOP_FUZZINGUTILS_H
#include <random>
/**
* Class that proposes random utility methods
*/
class RandomGenerator {
public:
/// @return the unique instance of the random generator
static RandomGenerator &instance();
/// Generates a random double between [min, max]
double generateDouble(double min, double max);
/// Generates a random int between [min, max]
int generateInt(int min, int max);
Alexandre Leroux
Fixes clang-format for resource files
r1211 /// Returns a random element among the elements of a container. If the container is empty,
/// returns an element built by default
Alexandre Leroux
Adds utility class to get random values
r1206 template <typename T, typename ValueType = typename T::value_type>
Alexandre Leroux
Fixes clang-format for resource files
r1211 ValueType randomChoice(const T &container);
Alexandre Leroux
Adds utility class to get random values
r1206
private:
std::mt19937 m_Mt;
explicit RandomGenerator();
};
Alexandre Leroux
Fixes clang-format for resource files
r1211 template <typename T, typename ValueType>
Alexandre Leroux
Adds utility class to get random values
r1206 ValueType RandomGenerator::randomChoice(const T &container)
{
Alexandre Leroux
Fixes clang-format for resource files
r1211 if (container.empty()) {
Alexandre Leroux
Adds utility class to get random values
r1206 return ValueType{};
}
auto randomIndex = generateInt(0, container.size() - 1);
return container.at(randomIndex);
}
#endif // SCIQLOP_FUZZINGUTILS