@@ -0,0 +1,26 | |||
|
1 | #include "FuzzingValidators.h" | |
|
2 | ||
|
3 | #include <functional> | |
|
4 | ||
|
5 | Q_LOGGING_CATEGORY(LOG_FuzzingValidators, "FuzzingValidators") | |
|
6 | ||
|
7 | namespace { | |
|
8 | ||
|
9 | /** | |
|
10 | * Default implementation of @sa IFuzzingValidator. This validator takes as parameter of its | |
|
11 | * construction a function of validation which is called in the validate() method | |
|
12 | */ | |
|
13 | class FuzzingValidator : public IFuzzingValidator { | |
|
14 | public: | |
|
15 | /// Signature of a validation function | |
|
16 | using ValidationFunction = std::function<void(const VariableState &variableState)>; | |
|
17 | ||
|
18 | explicit FuzzingValidator(ValidationFunction fun) : m_Fun(std::move(fun)) {} | |
|
19 | ||
|
20 | void validate(const VariableState &variableState) const override { m_Fun(variableState); } | |
|
21 | ||
|
22 | private: | |
|
23 | ValidationFunction m_Fun; | |
|
24 | }; | |
|
25 | ||
|
26 | } // namespace |
@@ -0,0 +1,21 | |||
|
1 | #ifndef SCIQLOP_FUZZINGVALIDATORS_H | |
|
2 | #define SCIQLOP_FUZZINGVALIDATORS_H | |
|
3 | ||
|
4 | #include <QLoggingCategory> | |
|
5 | ||
|
6 | Q_DECLARE_LOGGING_CATEGORY(LOG_FuzzingValidators) | |
|
7 | ||
|
8 | class VariableState; | |
|
9 | ||
|
10 | /** | |
|
11 | * Struct that represents a validator. A validator checks if the state of a variable is valid at the | |
|
12 | * moment it is called during a fuzzing test | |
|
13 | */ | |
|
14 | struct IFuzzingValidator { | |
|
15 | virtual ~IFuzzingValidator() noexcept = default; | |
|
16 | ||
|
17 | /// Validates the variable's state passed in parameter | |
|
18 | virtual void validate(const VariableState &variableState) const = 0; | |
|
19 | }; | |
|
20 | ||
|
21 | #endif // SCIQLOP_FUZZINGVALIDATORS_H |
@@ -72,7 +72,9 tests_sources = [ | |||
|
72 | 72 | 'tests/FuzzingOperations.h', |
|
73 | 73 | 'tests/FuzzingOperations.cpp', |
|
74 | 74 | 'tests/FuzzingUtils.h', |
|
75 | 'tests/FuzzingUtils.cpp' | |
|
75 | 'tests/FuzzingUtils.cpp', | |
|
76 | 'tests/FuzzingValidators.h', | |
|
77 | 'tests/FuzzingValidators.cpp' | |
|
76 | 78 | ] |
|
77 | 79 | |
|
78 | 80 | foreach unit_test : tests |
General Comments 0
You need to be logged in to leave comments.
Login now