diff --git a/plugins/amda/CMakeLists.txt b/plugins/amda/CMakeLists.txt index dcce263..ebcaf32 100644 --- a/plugins/amda/CMakeLists.txt +++ b/plugins/amda/CMakeLists.txt @@ -115,6 +115,7 @@ IF(BUILD_TESTS) ${testDirectory}/*.cpp ${testDirectory}/*.h) LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) + LIST(APPEND testFilesToFormat ${currentTestSources}) # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) diff --git a/plugins/amda/tests/FuzzingOperations.cpp b/plugins/amda/tests/FuzzingOperations.cpp index c917a2e..124ae35 100644 --- a/plugins/amda/tests/FuzzingOperations.cpp +++ b/plugins/amda/tests/FuzzingOperations.cpp @@ -13,34 +13,44 @@ Q_LOGGING_CATEGORY(LOG_FuzzingOperations, "FuzzingOperations") namespace { struct CreateOperation : public IFuzzingOperation { - bool canExecute(std::shared_ptr variable) const override { + bool canExecute(std::shared_ptr variable) const override + { // A variable can be created only if it doesn't exist yet return variable == nullptr; } - void execute(std::shared_ptr& variable, VariableController &variableController, const Properties &properties) const override{ - // Retrieves metadata pool from properties, and choose one of the metadata entries to associate it with the variable + void execute(std::shared_ptr &variable, VariableController &variableController, + const Properties &properties) const override + { + // Retrieves metadata pool from properties, and choose one of the metadata entries to + // associate it with the variable auto metaDataPool = properties.value(METADATA_POOL_PROPERTY).value(); auto variableMetadata = RandomGenerator::instance().randomChoice(metaDataPool); // Retrieves provider - auto variableProvider = properties.value(PROVIDER_PROPERTY).value>(); + auto variableProvider + = properties.value(PROVIDER_PROPERTY).value >(); auto variableName = QString{"Var_%1"}.arg(QUuid::createUuid().toString()); - qCInfo(LOG_FuzzingOperations()) << "Creating variable" << variableName << "(metadata:" << variableMetadata << ")"; + qCInfo(LOG_FuzzingOperations()) + << "Creating variable" << variableName << "(metadata:" << variableMetadata << ")"; - auto newVariable = variableController.createVariable(variableName, variableMetadata, variableProvider); + auto newVariable + = variableController.createVariable(variableName, variableMetadata, variableProvider); std::swap(variable, newVariable); } }; struct UnknownOperation : public IFuzzingOperation { - bool canExecute(std::shared_ptr variable) const override { + bool canExecute(std::shared_ptr variable) const override + { Q_UNUSED(variable); return false; } - void execute(std::shared_ptr& variable, VariableController &variableController, const Properties &properties) const override{ + void execute(std::shared_ptr &variable, VariableController &variableController, + const Properties &properties) const override + { Q_UNUSED(variable); Q_UNUSED(variableController); Q_UNUSED(properties); @@ -53,11 +63,11 @@ struct UnknownOperation : public IFuzzingOperation { std::unique_ptr FuzzingOperationFactory::create(FuzzingOperationType type) { switch (type) { - case FuzzingOperationType::CREATE: - return std::make_unique(); - default: - // Default case returns unknown operation - break; + case FuzzingOperationType::CREATE: + return std::make_unique(); + default: + // Default case returns unknown operation + break; } return std::make_unique(); diff --git a/plugins/amda/tests/FuzzingOperations.h b/plugins/amda/tests/FuzzingOperations.h index 6626eee..cbc3dc0 100644 --- a/plugins/amda/tests/FuzzingOperations.h +++ b/plugins/amda/tests/FuzzingOperations.h @@ -17,22 +17,24 @@ class VariableController; /** * Enumeration of types of existing fuzzing operations */ -enum class FuzzingOperationType { - CREATE -}; +enum class FuzzingOperationType { CREATE }; /// Interface that represents an operation that can be executed during a fuzzing test struct IFuzzingOperation { virtual ~IFuzzingOperation() noexcept = default; - /// Checks if the operation can be executed according to the current state of the variable passed in parameter + /// Checks if the operation can be executed according to the current state of the variable + /// passed in parameter virtual bool canExecute(std::shared_ptr variable) const = 0; /// Executes the operation on the variable passed in parameter /// @param variable the variable on which to execute the operation /// @param variableController the controller associated to the operation /// @param properties properties that can be used to configure the operation - /// @remarks variable is passed as a reference because, according to the operation, it can be modified (in/out parameter) - virtual void execute(std::shared_ptr &variable, VariableController& variableController, const Properties& properties = {}) const = 0; + /// @remarks variable is passed as a reference because, according to the operation, it can be + /// modified (in/out parameter) + virtual void execute(std::shared_ptr &variable, + VariableController &variableController, + const Properties &properties = {}) const = 0; }; /// Factory of @sa IFuzzingOperation diff --git a/plugins/amda/tests/FuzzingUtils.h b/plugins/amda/tests/FuzzingUtils.h index 87ff7cf..adfe293 100644 --- a/plugins/amda/tests/FuzzingUtils.h +++ b/plugins/amda/tests/FuzzingUtils.h @@ -16,9 +16,10 @@ public: /// Generates a random int between [min, max] int generateInt(int min, int max); - /// Returns a random element among the elements of a container. If the container is empty, returns an element built by default + /// Returns a random element among the elements of a container. If the container is empty, + /// returns an element built by default template - ValueType randomChoice(const T& container); + ValueType randomChoice(const T &container); private: std::mt19937 m_Mt; @@ -26,10 +27,10 @@ private: explicit RandomGenerator(); }; -template +template ValueType RandomGenerator::randomChoice(const T &container) { - if(container.empty()){ + if (container.empty()) { return ValueType{}; } @@ -38,4 +39,3 @@ ValueType RandomGenerator::randomChoice(const T &container) } #endif // SCIQLOP_FUZZINGUTILS -