##// END OF EJS Templates
Adds "number of operations" and "number of variables" properties for the tests
Adds "number of operations" and "number of variables" properties for the tests

File last commit:

r1201:3da18e6983d5
r1201:3da18e6983d5
Show More
TestAmdaFuzzing.cpp
117 lines | 2.8 KiB | text/x-c | CppLexer
/ plugins / amda / tests / TestAmdaFuzzing.cpp
Alexandre Leroux
Adds "number of operations" and "number of variables" properties for the tests
r1201 #include "FuzzingDefs.h"
Alexandre Leroux
Inits test structure
r1199 #include <Network/NetworkController.h>
#include <SqpApplication.h>
#include <Time/TimeController.h>
#include <Variable/VariableController.h>
#include <QLoggingCategory>
#include <QObject>
#include <QtTest>
#include <memory>
Q_LOGGING_CATEGORY(LOG_TestAmdaFuzzing, "TestAmdaFuzzing")
namespace {
Alexandre Leroux
Adds "number of operations" and "number of variables" properties for the tests
r1201 // ///////// //
// Constants //
// ///////// //
// Defaults values used when the associated properties have not been set for the test
const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 100;
const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 1;
Alexandre Leroux
Inits test structure
r1199 /**
* Class to run random tests
*/
class FuzzingTest {
public:
Alexandre Leroux
Adds variable controller and properties to test structure...
r1200 explicit FuzzingTest(VariableController &variableController, Properties properties)
: m_VariableController{variableController},
m_Properties{std::move(properties)},
{
}
Alexandre Leroux
Inits test structure
r1199 void execute()
{
/// @todo: complete
Alexandre Leroux
Adds "number of operations" and "number of variables" properties for the tests
r1201 qCInfo(LOG_TestAmdaFuzzing()) << "Running" << nbMaxOperations() << "operations on"
<< nbMaxVariables() << "variables...";
Alexandre Leroux
Inits test structure
r1199 qCInfo(LOG_TestAmdaFuzzing()) << "Execution of the test completed.";
}
Alexandre Leroux
Adds variable controller and properties to test structure...
r1200
private:
Alexandre Leroux
Adds "number of operations" and "number of variables" properties for the tests
r1201 int nbMaxOperations() const
{
static auto result
= m_Properties.value(NB_MAX_OPERATIONS_PROPERTY, NB_MAX_OPERATIONS_DEFAULT_VALUE)
.toInt();
return result;
}
int nbMaxVariables() const
{
static auto result
= m_Properties.value(NB_MAX_VARIABLES_PROPERTY, NB_MAX_VARIABLES_DEFAULT_VALUE).toInt();
return result;
}
Alexandre Leroux
Adds variable controller and properties to test structure...
r1200 VariableController &m_VariableController;
Properties m_Properties;
Alexandre Leroux
Inits test structure
r1199 };
} // namespace
class TestAmdaFuzzing : public QObject {
Q_OBJECT
private slots:
/// Input data for @sa testFuzzing()
void testFuzzing_data();
void testFuzzing();
};
void TestAmdaFuzzing::testFuzzing_data()
{
// ////////////// //
// Test structure //
// ////////////// //
Alexandre Leroux
Adds variable controller and properties to test structure...
r1200 QTest::addColumn<Properties>("properties"); // Properties for random test
Alexandre Leroux
Inits test structure
r1199
// ////////// //
// Test cases //
// ////////// //
///@todo: complete
}
void TestAmdaFuzzing::testFuzzing()
{
Alexandre Leroux
Adds variable controller and properties to test structure...
r1200 QFETCH(Properties, properties);
Alexandre Leroux
Inits test structure
r1199 auto &variableController = sqpApp->variableController();
auto &timeController = sqpApp->timeController();
Alexandre Leroux
Adds variable controller and properties to test structure...
r1200 FuzzingTest test{variableController, properties};
Alexandre Leroux
Inits test structure
r1199 test.execute();
}
int main(int argc, char *argv[])
{
QLoggingCategory::setFilterRules(
"*.warning=false\n"
"*.info=false\n"
"*.debug=false\n"
"FuzzingOperations.info=true\n"
"TestAmdaFuzzing.info=true\n");
SqpApplication app{argc, argv};
app.setAttribute(Qt::AA_Use96Dpi, true);
TestAmdaFuzzing testObject{};
QTEST_SET_MAIN_SOURCE_PATH
return QTest::qExec(&testObject, argc, argv);
}
#include "TestAmdaFuzzing.moc"