##// END OF EJS Templates
Fixes clang-format for resource files
Alexandre Leroux -
r1211:08e858e2cf84
parent child
Show More
@@ -115,6 +115,7 IF(BUILD_TESTS)
115 115 ${testDirectory}/*.cpp
116 116 ${testDirectory}/*.h)
117 117 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
118 LIST(APPEND testFilesToFormat ${currentTestSources})
118 119 # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
119 120
120 121 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
@@ -13,34 +13,44 Q_LOGGING_CATEGORY(LOG_FuzzingOperations, "FuzzingOperations")
13 13 namespace {
14 14
15 15 struct CreateOperation : public IFuzzingOperation {
16 bool canExecute(std::shared_ptr<Variable> variable) const override {
16 bool canExecute(std::shared_ptr<Variable> variable) const override
17 {
17 18 // A variable can be created only if it doesn't exist yet
18 19 return variable == nullptr;
19 20 }
20 21
21 void execute(std::shared_ptr<Variable>& variable, VariableController &variableController, const Properties &properties) const override{
22 // Retrieves metadata pool from properties, and choose one of the metadata entries to associate it with the variable
22 void execute(std::shared_ptr<Variable> &variable, VariableController &variableController,
23 const Properties &properties) const override
24 {
25 // Retrieves metadata pool from properties, and choose one of the metadata entries to
26 // associate it with the variable
23 27 auto metaDataPool = properties.value(METADATA_POOL_PROPERTY).value<MetadataPool>();
24 28 auto variableMetadata = RandomGenerator::instance().randomChoice(metaDataPool);
25 29
26 30 // Retrieves provider
27 auto variableProvider = properties.value(PROVIDER_PROPERTY).value<std::shared_ptr<IDataProvider>>();
31 auto variableProvider
32 = properties.value(PROVIDER_PROPERTY).value<std::shared_ptr<IDataProvider> >();
28 33
29 34 auto variableName = QString{"Var_%1"}.arg(QUuid::createUuid().toString());
30 qCInfo(LOG_FuzzingOperations()) << "Creating variable" << variableName << "(metadata:" << variableMetadata << ")";
35 qCInfo(LOG_FuzzingOperations())
36 << "Creating variable" << variableName << "(metadata:" << variableMetadata << ")";
31 37
32 auto newVariable = variableController.createVariable(variableName, variableMetadata, variableProvider);
38 auto newVariable
39 = variableController.createVariable(variableName, variableMetadata, variableProvider);
33 40 std::swap(variable, newVariable);
34 41 }
35 42 };
36 43
37 44 struct UnknownOperation : public IFuzzingOperation {
38 bool canExecute(std::shared_ptr<Variable> variable) const override {
45 bool canExecute(std::shared_ptr<Variable> variable) const override
46 {
39 47 Q_UNUSED(variable);
40 48 return false;
41 49 }
42 50
43 void execute(std::shared_ptr<Variable>& variable, VariableController &variableController, const Properties &properties) const override{
51 void execute(std::shared_ptr<Variable> &variable, VariableController &variableController,
52 const Properties &properties) const override
53 {
44 54 Q_UNUSED(variable);
45 55 Q_UNUSED(variableController);
46 56 Q_UNUSED(properties);
@@ -53,11 +63,11 struct UnknownOperation : public IFuzzingOperation {
53 63 std::unique_ptr<IFuzzingOperation> FuzzingOperationFactory::create(FuzzingOperationType type)
54 64 {
55 65 switch (type) {
56 case FuzzingOperationType::CREATE:
57 return std::make_unique<CreateOperation>();
58 default:
59 // Default case returns unknown operation
60 break;
66 case FuzzingOperationType::CREATE:
67 return std::make_unique<CreateOperation>();
68 default:
69 // Default case returns unknown operation
70 break;
61 71 }
62 72
63 73 return std::make_unique<UnknownOperation>();
@@ -17,22 +17,24 class VariableController;
17 17 /**
18 18 * Enumeration of types of existing fuzzing operations
19 19 */
20 enum class FuzzingOperationType {
21 CREATE
22 };
20 enum class FuzzingOperationType { CREATE };
23 21
24 22 /// Interface that represents an operation that can be executed during a fuzzing test
25 23 struct IFuzzingOperation {
26 24 virtual ~IFuzzingOperation() noexcept = default;
27 25
28 /// Checks if the operation can be executed according to the current state of the variable passed in parameter
26 /// Checks if the operation can be executed according to the current state of the variable
27 /// passed in parameter
29 28 virtual bool canExecute(std::shared_ptr<Variable> variable) const = 0;
30 29 /// Executes the operation on the variable passed in parameter
31 30 /// @param variable the variable on which to execute the operation
32 31 /// @param variableController the controller associated to the operation
33 32 /// @param properties properties that can be used to configure the operation
34 /// @remarks variable is passed as a reference because, according to the operation, it can be modified (in/out parameter)
35 virtual void execute(std::shared_ptr<Variable> &variable, VariableController& variableController, const Properties& properties = {}) const = 0;
33 /// @remarks variable is passed as a reference because, according to the operation, it can be
34 /// modified (in/out parameter)
35 virtual void execute(std::shared_ptr<Variable> &variable,
36 VariableController &variableController,
37 const Properties &properties = {}) const = 0;
36 38 };
37 39
38 40 /// Factory of @sa IFuzzingOperation
@@ -16,9 +16,10 public:
16 16 /// Generates a random int between [min, max]
17 17 int generateInt(int min, int max);
18 18
19 /// Returns a random element among the elements of a container. If the container is empty, returns an element built by default
19 /// Returns a random element among the elements of a container. If the container is empty,
20 /// returns an element built by default
20 21 template <typename T, typename ValueType = typename T::value_type>
21 ValueType randomChoice(const T& container);
22 ValueType randomChoice(const T &container);
22 23
23 24 private:
24 25 std::mt19937 m_Mt;
@@ -26,10 +27,10 private:
26 27 explicit RandomGenerator();
27 28 };
28 29
29 template<typename T, typename ValueType>
30 template <typename T, typename ValueType>
30 31 ValueType RandomGenerator::randomChoice(const T &container)
31 32 {
32 if(container.empty()){
33 if (container.empty()) {
33 34 return ValueType{};
34 35 }
35 36
@@ -38,4 +39,3 ValueType RandomGenerator::randomChoice(const T &container)
38 39 }
39 40
40 41 #endif // SCIQLOP_FUZZINGUTILS
41
General Comments 0
You need to be logged in to leave comments. Login now