6#include "../namespaces.h"
8#include "../utilities/semantics/generator_handler.h"
10#include <catch/catch.hpp>
21 QStringGenerator(Catch::Generators::GeneratorWrapper<QChar>&& character_generator, qsizetype minimum_length, qsizetype maximum_length)
23 random_engine{
std::random_device{}()},
27 assert(minimum_length >= 0);
28 assert(maximum_length >= 0);
29 assert(minimum_length <= maximum_length);
32 Catch::throw_exception(
"Not enough values to initialize the first string");
35 QString const&
get()
const override {
return current_string; }
38 qsizetype length{length_distribution(random_engine)};
40 current_string = QString();
41 for (qsizetype length_index{0}; length_index < length; ++length_index) {
42 if (!character_generator.next())
return false;
44 current_string += character_generator.get();
51 Catch::Generators::GeneratorWrapper<QChar> character_generator;
53 std::mt19937 random_engine;
54 std::uniform_int_distribution<qsizetype> length_distribution;
56 QString current_string;
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
80 return Catch::Generators::GeneratorWrapper<QString>(std::unique_ptr<Catch::Generators::IGenerator<QString>>(
new QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::QStringGenerator(std::move(character_generator), minimum_length, maximum_length)));
84
85
86
QStringGenerator(Catch::Generators::GeneratorWrapper< QChar > &&character_generator, qsizetype minimum_length, qsizetype maximum_length)
QString const & get() const override
Catch::Generators::GeneratorWrapper< QString > empty_string()
Returns an infinite generator whose elements are the empty QString.
Catch::Generators::GeneratorWrapper< QString > string(Catch::Generators::GeneratorWrapper< QChar > &&character_generator, qsizetype minimum_length, qsizetype maximum_length)
Returns a generator that generates elements of QString from some amount of elements taken from charac...
#define QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE
#define QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE
#define QDOC_CATCH_GENERATORS_ROOT_NAMESPACE