##// END OF EJS Templates
Adds validators to the fuzzing test...
Adds validators to the fuzzing test As for operations, we define a set of validators that will be called to validate a state after an operation

File last commit:

r1194:60a45a0d7167
r1195:6bf9a231f6d8
Show More
FuzzingValidators.cpp
49 lines | 1.5 KiB | text/x-c | CppLexer
/ plugins / amda / tests / FuzzingValidators.cpp
Alexandre Leroux
Creates validator interface
r1193 #include "FuzzingValidators.h"
Alexandre Leroux
Creates validators for range and data
r1194 #include <QTest>
Alexandre Leroux
Creates validator interface
r1193 #include <functional>
Q_LOGGING_CATEGORY(LOG_FuzzingValidators, "FuzzingValidators")
namespace {
/**
* Default implementation of @sa IFuzzingValidator. This validator takes as parameter of its
* construction a function of validation which is called in the validate() method
*/
class FuzzingValidator : public IFuzzingValidator {
public:
/// Signature of a validation function
using ValidationFunction = std::function<void(const VariableState &variableState)>;
explicit FuzzingValidator(ValidationFunction fun) : m_Fun(std::move(fun)) {}
void validate(const VariableState &variableState) const override { m_Fun(variableState); }
private:
ValidationFunction m_Fun;
};
} // namespace
Alexandre Leroux
Creates validators for range and data
r1194
std::unique_ptr<IFuzzingValidator> FuzzingValidatorFactory::create(FuzzingValidatorType type)
{
switch (type) {
case FuzzingValidatorType::DATA:
return std::make_unique<FuzzingValidator>([](const VariableState &variableState) {
/// @todo: complete
});
case FuzzingValidatorType::RANGE:
return std::make_unique<FuzzingValidator>([](const VariableState &variableState) {
/// @todo: complete
});
default:
// Default case returns invalid validator
break;
}
// Invalid validator
return std::make_unique<FuzzingValidator>(
[](const VariableState &) { QFAIL("Invalid validator"); });
}