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