@@ -1,5 +1,7 | |||||
1 | #include "FuzzingValidators.h" |
|
1 | #include "FuzzingValidators.h" | |
2 |
|
2 | |||
|
3 | #include <QTest> | |||
|
4 | ||||
3 | #include <functional> |
|
5 | #include <functional> | |
4 |
|
6 | |||
5 | Q_LOGGING_CATEGORY(LOG_FuzzingValidators, "FuzzingValidators") |
|
7 | Q_LOGGING_CATEGORY(LOG_FuzzingValidators, "FuzzingValidators") | |
@@ -24,3 +26,24 private: | |||||
24 | }; |
|
26 | }; | |
25 |
|
27 | |||
26 | } // namespace |
|
28 | } // namespace | |
|
29 | ||||
|
30 | std::unique_ptr<IFuzzingValidator> FuzzingValidatorFactory::create(FuzzingValidatorType type) | |||
|
31 | { | |||
|
32 | switch (type) { | |||
|
33 | case FuzzingValidatorType::DATA: | |||
|
34 | return std::make_unique<FuzzingValidator>([](const VariableState &variableState) { | |||
|
35 | /// @todo: complete | |||
|
36 | }); | |||
|
37 | case FuzzingValidatorType::RANGE: | |||
|
38 | return std::make_unique<FuzzingValidator>([](const VariableState &variableState) { | |||
|
39 | /// @todo: complete | |||
|
40 | }); | |||
|
41 | default: | |||
|
42 | // Default case returns invalid validator | |||
|
43 | break; | |||
|
44 | } | |||
|
45 | ||||
|
46 | // Invalid validator | |||
|
47 | return std::make_unique<FuzzingValidator>( | |||
|
48 | [](const VariableState &) { QFAIL("Invalid validator"); }); | |||
|
49 | } |
@@ -7,6 +7,12 Q_DECLARE_LOGGING_CATEGORY(LOG_FuzzingValidators) | |||||
7 |
|
7 | |||
8 | class VariableState; |
|
8 | class VariableState; | |
9 |
|
9 | |||
|
10 | /// Types of validators that can be defined | |||
|
11 | enum class FuzzingValidatorType { | |||
|
12 | DATA, ///< Validates variable's data | |||
|
13 | RANGE ///< Validates variable's range | |||
|
14 | }; | |||
|
15 | ||||
10 | /** |
|
16 | /** | |
11 | * Struct that represents a validator. A validator checks if the state of a variable is valid at the |
|
17 | * 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 |
|
18 | * moment it is called during a fuzzing test | |
@@ -18,4 +24,10 struct IFuzzingValidator { | |||||
18 | virtual void validate(const VariableState &variableState) const = 0; |
|
24 | virtual void validate(const VariableState &variableState) const = 0; | |
19 | }; |
|
25 | }; | |
20 |
|
26 | |||
|
27 | /// Factory of @sa IFuzzingValidator | |||
|
28 | struct FuzzingValidatorFactory { | |||
|
29 | /// Creates a validator according to the type passed in parameter | |||
|
30 | static std::unique_ptr<IFuzzingValidator> create(FuzzingValidatorType type); | |||
|
31 | }; | |||
|
32 | ||||
21 | #endif // SCIQLOP_FUZZINGVALIDATORS_H |
|
33 | #endif // SCIQLOP_FUZZINGVALIDATORS_H |
General Comments 0
You need to be logged in to leave comments.
Login now