##// END OF EJS Templates
Adds "number of operations" and "number of variables" properties for the tests
Alexandre Leroux -
r1170:3da18e6983d5
parent child
Show More
@@ -1,2 +1,4
1 1 #include "FuzzingDefs.h"
2 2
3 const QString NB_MAX_OPERATIONS_PROPERTY = QStringLiteral("component");
4 const QString NB_MAX_VARIABLES_PROPERTY = QStringLiteral("nbMaxVariables");
@@ -1,10 +1,21
1 1 #ifndef SCIQLOP_FUZZINGDEFS_H
2 2 #define SCIQLOP_FUZZINGDEFS_H
3 3
4 #include <QString>
4 5 // /////// //
5 6 // Aliases //
6 7 // /////// //
7 8
8 9 using Properties = QVariantHash;
9 10
11 // ///////// //
12 // Constants //
13 // ///////// //
14
15 /// Max number of operations to generate
16 extern const QString NB_MAX_OPERATIONS_PROPERTY;
17
18 /// Max number of variables to manipulate through operations
19 extern const QString NB_MAX_VARIABLES_PROPERTY;
20
10 21 #endif // SCIQLOP_FUZZINGDEFS_H
@@ -1,91 +1,117
1 #include "FuzzingDefs.h"
1 2 #include <Network/NetworkController.h>
2 3 #include <SqpApplication.h>
3 4 #include <Time/TimeController.h>
4 5 #include <Variable/VariableController.h>
5 6
6 7 #include <QLoggingCategory>
7 8 #include <QObject>
8 9 #include <QtTest>
9 10
10 11 #include <memory>
11 12
12 13 Q_LOGGING_CATEGORY(LOG_TestAmdaFuzzing, "TestAmdaFuzzing")
13 14
14 15 namespace {
15 16
17 // ///////// //
18 // Constants //
19 // ///////// //
20
21 // Defaults values used when the associated properties have not been set for the test
22 const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 100;
23 const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 1;
16 24 /**
17 25 * Class to run random tests
18 26 */
19 27 class FuzzingTest {
20 28 public:
21 29 explicit FuzzingTest(VariableController &variableController, Properties properties)
22 30 : m_VariableController{variableController},
23 31 m_Properties{std::move(properties)},
24 32 {
25 33 }
26 34
27 35 void execute()
28 36 {
29 37 /// @todo: complete
38 qCInfo(LOG_TestAmdaFuzzing()) << "Running" << nbMaxOperations() << "operations on"
39 << nbMaxVariables() << "variables...";
40
30 41 qCInfo(LOG_TestAmdaFuzzing()) << "Execution of the test completed.";
31 42 }
32 43
33 44 private:
45 int nbMaxOperations() const
46 {
47 static auto result
48 = m_Properties.value(NB_MAX_OPERATIONS_PROPERTY, NB_MAX_OPERATIONS_DEFAULT_VALUE)
49 .toInt();
50 return result;
51 }
52
53 int nbMaxVariables() const
54 {
55 static auto result
56 = m_Properties.value(NB_MAX_VARIABLES_PROPERTY, NB_MAX_VARIABLES_DEFAULT_VALUE).toInt();
57 return result;
58 }
59
34 60 VariableController &m_VariableController;
35 61 Properties m_Properties;
36 62 };
37 63
38 64 } // namespace
39 65
40 66 class TestAmdaFuzzing : public QObject {
41 67 Q_OBJECT
42 68
43 69 private slots:
44 70 /// Input data for @sa testFuzzing()
45 71 void testFuzzing_data();
46 72 void testFuzzing();
47 73 };
48 74
49 75 void TestAmdaFuzzing::testFuzzing_data()
50 76 {
51 77 // ////////////// //
52 78 // Test structure //
53 79 // ////////////// //
54 80
55 81 QTest::addColumn<Properties>("properties"); // Properties for random test
56 82
57 83 // ////////// //
58 84 // Test cases //
59 85 // ////////// //
60 86
61 87 ///@todo: complete
62 88 }
63 89
64 90 void TestAmdaFuzzing::testFuzzing()
65 91 {
66 92 QFETCH(Properties, properties);
67 93
68 94 auto &variableController = sqpApp->variableController();
69 95 auto &timeController = sqpApp->timeController();
70 96
71 97 FuzzingTest test{variableController, properties};
72 98 test.execute();
73 99 }
74 100
75 101 int main(int argc, char *argv[])
76 102 {
77 103 QLoggingCategory::setFilterRules(
78 104 "*.warning=false\n"
79 105 "*.info=false\n"
80 106 "*.debug=false\n"
81 107 "FuzzingOperations.info=true\n"
82 108 "TestAmdaFuzzing.info=true\n");
83 109
84 110 SqpApplication app{argc, argv};
85 111 app.setAttribute(Qt::AA_Use96Dpi, true);
86 112 TestAmdaFuzzing testObject{};
87 113 QTEST_SET_MAIN_SOURCE_PATH
88 114 return QTest::qExec(&testObject, argc, argv);
89 115 }
90 116
91 117 #include "TestAmdaFuzzing.moc"
General Comments 0
You need to be logged in to leave comments. Login now