##// END OF EJS Templates
Handles y-axis in the unit tests...
Alexandre Leroux -
r969:299bc9e2c2bd
parent child
Show More
@@ -1,317 +1,357
1 #include "AmdaResultParser.h"
1 #include "AmdaResultParser.h"
2
2
3 #include <Data/ScalarSeries.h>
3 #include <Data/ScalarSeries.h>
4 #include <Data/VectorSeries.h>
4 #include <Data/VectorSeries.h>
5
5
6 #include <QObject>
6 #include <QObject>
7 #include <QtTest>
7 #include <QtTest>
8
8
9 namespace {
9 namespace {
10
10
11 /// Path for the tests
11 /// Path for the tests
12 const auto TESTS_RESOURCES_PATH
12 const auto TESTS_RESOURCES_PATH
13 = QFileInfo{QString{AMDA_TESTS_RESOURCES_DIR}, "TestAmdaResultParser"}.absoluteFilePath();
13 = QFileInfo{QString{AMDA_TESTS_RESOURCES_DIR}, "TestAmdaResultParser"}.absoluteFilePath();
14
14
15 QDateTime dateTime(int year, int month, int day, int hours, int minutes, int seconds)
15 QDateTime dateTime(int year, int month, int day, int hours, int minutes, int seconds)
16 {
16 {
17 return QDateTime{{year, month, day}, {hours, minutes, seconds}, Qt::UTC};
17 return QDateTime{{year, month, day}, {hours, minutes, seconds}, Qt::UTC};
18 }
18 }
19
19
20 QString inputFilePath(const QString &inputFileName)
20 QString inputFilePath(const QString &inputFileName)
21 {
21 {
22 return QFileInfo{TESTS_RESOURCES_PATH, inputFileName}.absoluteFilePath();
22 return QFileInfo{TESTS_RESOURCES_PATH, inputFileName}.absoluteFilePath();
23 }
23 }
24
24
25 template <typename T>
25 template <typename T>
26 struct ExpectedResults {
26 struct ExpectedResults {
27
27
28 ExpectedResults &setParsingOK(bool parsingOK)
28 ExpectedResults &setParsingOK(bool parsingOK)
29 {
29 {
30 m_ParsingOK = parsingOK;
30 m_ParsingOK = parsingOK;
31 return *this;
31 return *this;
32 }
32 }
33
33
34 ExpectedResults &setXAxisUnit(Unit xAxisUnit)
34 ExpectedResults &setXAxisUnit(Unit xAxisUnit)
35 {
35 {
36 m_XAxisUnit = std::move(xAxisUnit);
36 m_XAxisUnit = std::move(xAxisUnit);
37 return *this;
37 return *this;
38 }
38 }
39
39
40 ExpectedResults &setXAxisData(const QVector<QDateTime> &xAxisData)
40 ExpectedResults &setXAxisData(const QVector<QDateTime> &xAxisData)
41 {
41 {
42 m_XAxisData.clear();
42 m_XAxisData.clear();
43
43
44 // Converts QVector<QDateTime> to QVector<double>
44 // Converts QVector<QDateTime> to QVector<double>
45 std::transform(xAxisData.cbegin(), xAxisData.cend(), std::back_inserter(m_XAxisData),
45 std::transform(xAxisData.cbegin(), xAxisData.cend(), std::back_inserter(m_XAxisData),
46 [](const auto &dateTime) { return dateTime.toMSecsSinceEpoch() / 1000.; });
46 [](const auto &dateTime) { return dateTime.toMSecsSinceEpoch() / 1000.; });
47
47
48 return *this;
48 return *this;
49 }
49 }
50
50
51 ExpectedResults &setValuesUnit(Unit valuesUnit)
51 ExpectedResults &setValuesUnit(Unit valuesUnit)
52 {
52 {
53 m_ValuesUnit = std::move(valuesUnit);
53 m_ValuesUnit = std::move(valuesUnit);
54 return *this;
54 return *this;
55 }
55 }
56
56
57 ExpectedResults &setValuesData(QVector<double> valuesData)
57 ExpectedResults &setValuesData(QVector<double> valuesData)
58 {
58 {
59 m_ValuesData.clear();
59 m_ValuesData.clear();
60 m_ValuesData.push_back(std::move(valuesData));
60 m_ValuesData.push_back(std::move(valuesData));
61 return *this;
61 return *this;
62 }
62 }
63
63
64 ExpectedResults &setValuesData(QVector<QVector<double> > valuesData)
64 ExpectedResults &setValuesData(QVector<QVector<double> > valuesData)
65 {
65 {
66 m_ValuesData = std::move(valuesData);
66 m_ValuesData = std::move(valuesData);
67 return *this;
67 return *this;
68 }
68 }
69
69
70 ExpectedResults &setYAxisEnabled(bool yAxisEnabled)
71 {
72 m_YAxisEnabled = yAxisEnabled;
73 return *this;
74 }
75
76 ExpectedResults &setYAxisUnit(Unit yAxisUnit)
77 {
78 m_YAxisUnit = std::move(yAxisUnit);
79 return *this;
80 }
81
82 ExpectedResults &setYAxisData(QVector<double> yAxisData)
83 {
84 m_YAxisData = std::move(yAxisData);
85 return *this;
86 }
87
70 /**
88 /**
71 * Validates a DataSeries compared to the expected results
89 * Validates a DataSeries compared to the expected results
72 * @param results the DataSeries to validate
90 * @param results the DataSeries to validate
73 */
91 */
74 void validate(std::shared_ptr<IDataSeries> results)
92 void validate(std::shared_ptr<IDataSeries> results)
75 {
93 {
76 if (m_ParsingOK) {
94 if (m_ParsingOK) {
77 auto dataSeries = dynamic_cast<T *>(results.get());
95 auto dataSeries = dynamic_cast<T *>(results.get());
78 if (dataSeries == nullptr) {
96 if (dataSeries == nullptr) {
79
97
80 // No unit detected, parsink ok but data is nullptr
98 // No unit detected, parsink ok but data is nullptr
81 // TODO, improve the test to verify that the data is null
99 // TODO, improve the test to verify that the data is null
82 return;
100 return;
83 }
101 }
84
102
85 // Checks units
103 // Checks units
86 QVERIFY(dataSeries->xAxisUnit() == m_XAxisUnit);
104 QVERIFY(dataSeries->xAxisUnit() == m_XAxisUnit);
87 QVERIFY(dataSeries->valuesUnit() == m_ValuesUnit);
105 QVERIFY(dataSeries->valuesUnit() == m_ValuesUnit);
88
106
89 auto verifyRange = [dataSeries](const auto &expectedData, const auto &equalFun) {
107 auto verifyRange = [dataSeries](const auto &expectedData, const auto &equalFun) {
90 QVERIFY(std::equal(dataSeries->cbegin(), dataSeries->cend(), expectedData.cbegin(),
108 QVERIFY(std::equal(dataSeries->cbegin(), dataSeries->cend(), expectedData.cbegin(),
91 expectedData.cend(),
109 expectedData.cend(),
92 [&equalFun](const auto &dataSeriesIt, const auto &expectedX) {
110 [&equalFun](const auto &dataSeriesIt, const auto &expectedX) {
93 return equalFun(dataSeriesIt, expectedX);
111 return equalFun(dataSeriesIt, expectedX);
94 }));
112 }));
95 };
113 };
96
114
97 // Checks x-axis data
115 // Checks x-axis data
98 verifyRange(m_XAxisData, [](const auto &seriesIt, const auto &value) {
116 verifyRange(m_XAxisData, [](const auto &seriesIt, const auto &value) {
99 return seriesIt.x() == value;
117 return seriesIt.x() == value;
100 });
118 });
101
119
102 // Checks values data of each component
120 // Checks values data of each component
103 for (auto i = 0; i < m_ValuesData.size(); ++i) {
121 for (auto i = 0; i < m_ValuesData.size(); ++i) {
104 verifyRange(m_ValuesData.at(i), [i](const auto &seriesIt, const auto &value) {
122 verifyRange(m_ValuesData.at(i), [i](const auto &seriesIt, const auto &value) {
105 auto itValue = seriesIt.value(i);
123 auto itValue = seriesIt.value(i);
106 return (std::isnan(itValue) && std::isnan(value)) || seriesIt.value(i) == value;
124 return (std::isnan(itValue) && std::isnan(value)) || seriesIt.value(i) == value;
107 });
125 });
108 }
126 }
127
128 // Checks y-axis (if defined)
129 auto yAxis = dataSeries->yAxis();
130 QCOMPARE(yAxis.isDefined(), m_YAxisEnabled);
131
132 if (m_YAxisEnabled) {
133 // Unit
134 QCOMPARE(yAxis.unit(), m_YAxisUnit);
135
136 // Data
137 auto yAxisSize = yAxis.size();
138 QCOMPARE(yAxisSize, m_YAxisData.size());
139 for (auto i = 0; i < yAxisSize; ++i) {
140 QCOMPARE(yAxis.at(i), m_YAxisData.at(i));
141 }
142 }
109 }
143 }
110 else {
144 else {
111 QVERIFY(results == nullptr);
145 QVERIFY(results == nullptr);
112 }
146 }
113 }
147 }
114
148
115 // Parsing was successfully completed
149 // Parsing was successfully completed
116 bool m_ParsingOK{false};
150 bool m_ParsingOK{false};
117 // Expected x-axis unit
151 // Expected x-axis unit
118 Unit m_XAxisUnit{};
152 Unit m_XAxisUnit{};
119 // Expected x-axis data
153 // Expected x-axis data
120 QVector<double> m_XAxisData{};
154 QVector<double> m_XAxisData{};
121 // Expected values unit
155 // Expected values unit
122 Unit m_ValuesUnit{};
156 Unit m_ValuesUnit{};
123 // Expected values data
157 // Expected values data
124 QVector<QVector<double> > m_ValuesData{};
158 QVector<QVector<double> > m_ValuesData{};
159 // Expected data series has y-axis
160 bool m_YAxisEnabled{false};
161 // Expected y-axis unit (if axis defined)
162 Unit m_YAxisUnit{};
163 // Expected y-axis data (if axis defined)
164 QVector<double> m_YAxisData{};
125 };
165 };
126
166
127 } // namespace
167 } // namespace
128
168
129 Q_DECLARE_METATYPE(ExpectedResults<ScalarSeries>)
169 Q_DECLARE_METATYPE(ExpectedResults<ScalarSeries>)
130 Q_DECLARE_METATYPE(ExpectedResults<VectorSeries>)
170 Q_DECLARE_METATYPE(ExpectedResults<VectorSeries>)
131
171
132 class TestAmdaResultParser : public QObject {
172 class TestAmdaResultParser : public QObject {
133 Q_OBJECT
173 Q_OBJECT
134 private:
174 private:
135 template <typename T>
175 template <typename T>
136 void testReadDataStructure()
176 void testReadDataStructure()
137 {
177 {
138 // ////////////// //
178 // ////////////// //
139 // Test structure //
179 // Test structure //
140 // ////////////// //
180 // ////////////// //
141
181
142 // Name of TXT file to read
182 // Name of TXT file to read
143 QTest::addColumn<QString>("inputFileName");
183 QTest::addColumn<QString>("inputFileName");
144 // Expected results
184 // Expected results
145 QTest::addColumn<ExpectedResults<T> >("expectedResults");
185 QTest::addColumn<ExpectedResults<T> >("expectedResults");
146 }
186 }
147
187
148 template <typename T>
188 template <typename T>
149 void testRead(AmdaResultParser::ValueType valueType)
189 void testRead(AmdaResultParser::ValueType valueType)
150 {
190 {
151 QFETCH(QString, inputFileName);
191 QFETCH(QString, inputFileName);
152 QFETCH(ExpectedResults<T>, expectedResults);
192 QFETCH(ExpectedResults<T>, expectedResults);
153
193
154 // Parses file
194 // Parses file
155 auto filePath = inputFilePath(inputFileName);
195 auto filePath = inputFilePath(inputFileName);
156 auto results = AmdaResultParser::readTxt(filePath, valueType);
196 auto results = AmdaResultParser::readTxt(filePath, valueType);
157
197
158 // ///////////////// //
198 // ///////////////// //
159 // Validates results //
199 // Validates results //
160 // ///////////////// //
200 // ///////////////// //
161 expectedResults.validate(results);
201 expectedResults.validate(results);
162 }
202 }
163
203
164 private slots:
204 private slots:
165 /// Input test data
205 /// Input test data
166 /// @sa testReadScalarTxt()
206 /// @sa testReadScalarTxt()
167 void testReadScalarTxt_data();
207 void testReadScalarTxt_data();
168
208
169 /// Tests parsing scalar series of a TXT file
209 /// Tests parsing scalar series of a TXT file
170 void testReadScalarTxt();
210 void testReadScalarTxt();
171
211
172 /// Input test data
212 /// Input test data
173 /// @sa testReadVectorTxt()
213 /// @sa testReadVectorTxt()
174 void testReadVectorTxt_data();
214 void testReadVectorTxt_data();
175
215
176 /// Tests parsing vector series of a TXT file
216 /// Tests parsing vector series of a TXT file
177 void testReadVectorTxt();
217 void testReadVectorTxt();
178 };
218 };
179
219
180 void TestAmdaResultParser::testReadScalarTxt_data()
220 void TestAmdaResultParser::testReadScalarTxt_data()
181 {
221 {
182 testReadDataStructure<ScalarSeries>();
222 testReadDataStructure<ScalarSeries>();
183
223
184 // ////////// //
224 // ////////// //
185 // Test cases //
225 // Test cases //
186 // ////////// //
226 // ////////// //
187
227
188 // Valid files
228 // Valid files
189 QTest::newRow("Valid file")
229 QTest::newRow("Valid file")
190 << QStringLiteral("ValidScalar1.txt")
230 << QStringLiteral("ValidScalar1.txt")
191 << ExpectedResults<ScalarSeries>{}
231 << ExpectedResults<ScalarSeries>{}
192 .setParsingOK(true)
232 .setParsingOK(true)
193 .setXAxisUnit(Unit{"nT", true})
233 .setXAxisUnit(Unit{"nT", true})
194 .setXAxisData({dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
234 .setXAxisData({dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
195 dateTime(2013, 9, 23, 9, 2, 30), dateTime(2013, 9, 23, 9, 3, 30),
235 dateTime(2013, 9, 23, 9, 2, 30), dateTime(2013, 9, 23, 9, 3, 30),
196 dateTime(2013, 9, 23, 9, 4, 30), dateTime(2013, 9, 23, 9, 5, 30),
236 dateTime(2013, 9, 23, 9, 4, 30), dateTime(2013, 9, 23, 9, 5, 30),
197 dateTime(2013, 9, 23, 9, 6, 30), dateTime(2013, 9, 23, 9, 7, 30),
237 dateTime(2013, 9, 23, 9, 6, 30), dateTime(2013, 9, 23, 9, 7, 30),
198 dateTime(2013, 9, 23, 9, 8, 30), dateTime(2013, 9, 23, 9, 9, 30)})
238 dateTime(2013, 9, 23, 9, 8, 30), dateTime(2013, 9, 23, 9, 9, 30)})
199 .setValuesData({-2.83950, -2.71850, -2.52150, -2.57633, -2.58050, -2.48325, -2.63025,
239 .setValuesData({-2.83950, -2.71850, -2.52150, -2.57633, -2.58050, -2.48325, -2.63025,
200 -2.55800, -2.43250, -2.42200});
240 -2.55800, -2.43250, -2.42200});
201
241
202 QTest::newRow("Valid file (value of first line is invalid but it is converted to NaN")
242 QTest::newRow("Valid file (value of first line is invalid but it is converted to NaN")
203 << QStringLiteral("WrongValue.txt")
243 << QStringLiteral("WrongValue.txt")
204 << ExpectedResults<ScalarSeries>{}
244 << ExpectedResults<ScalarSeries>{}
205 .setParsingOK(true)
245 .setParsingOK(true)
206 .setXAxisUnit(Unit{"nT", true})
246 .setXAxisUnit(Unit{"nT", true})
207 .setXAxisData({dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
247 .setXAxisData({dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
208 dateTime(2013, 9, 23, 9, 2, 30)})
248 dateTime(2013, 9, 23, 9, 2, 30)})
209 .setValuesData({std::numeric_limits<double>::quiet_NaN(), -2.71850, -2.52150});
249 .setValuesData({std::numeric_limits<double>::quiet_NaN(), -2.71850, -2.52150});
210
250
211 QTest::newRow("Valid file that contains NaN values")
251 QTest::newRow("Valid file that contains NaN values")
212 << QStringLiteral("NaNValue.txt")
252 << QStringLiteral("NaNValue.txt")
213 << ExpectedResults<ScalarSeries>{}
253 << ExpectedResults<ScalarSeries>{}
214 .setParsingOK(true)
254 .setParsingOK(true)
215 .setXAxisUnit(Unit{("nT"), true})
255 .setXAxisUnit(Unit{("nT"), true})
216 .setXAxisData({dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
256 .setXAxisData({dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
217 dateTime(2013, 9, 23, 9, 2, 30)})
257 dateTime(2013, 9, 23, 9, 2, 30)})
218 .setValuesData({std::numeric_limits<double>::quiet_NaN(), -2.71850, -2.52150});
258 .setValuesData({std::numeric_limits<double>::quiet_NaN(), -2.71850, -2.52150});
219
259
220 // Valid files but with some invalid lines (wrong unit, wrong values, etc.)
260 // Valid files but with some invalid lines (wrong unit, wrong values, etc.)
221 QTest::newRow("No unit file")
261 QTest::newRow("No unit file")
222 << QStringLiteral("NoUnit.txt")
262 << QStringLiteral("NoUnit.txt")
223 << ExpectedResults<ScalarSeries>{}.setParsingOK(true).setXAxisUnit(Unit{"", true});
263 << ExpectedResults<ScalarSeries>{}.setParsingOK(true).setXAxisUnit(Unit{"", true});
224
264
225 QTest::newRow("Wrong unit file")
265 QTest::newRow("Wrong unit file")
226 << QStringLiteral("WrongUnit.txt")
266 << QStringLiteral("WrongUnit.txt")
227 << ExpectedResults<ScalarSeries>{}
267 << ExpectedResults<ScalarSeries>{}
228 .setParsingOK(true)
268 .setParsingOK(true)
229 .setXAxisUnit(Unit{"", true})
269 .setXAxisUnit(Unit{"", true})
230 .setXAxisData({dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
270 .setXAxisData({dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
231 dateTime(2013, 9, 23, 9, 2, 30)})
271 dateTime(2013, 9, 23, 9, 2, 30)})
232 .setValuesData({-2.83950, -2.71850, -2.52150});
272 .setValuesData({-2.83950, -2.71850, -2.52150});
233
273
234 QTest::newRow("Wrong results file (date of first line is invalid")
274 QTest::newRow("Wrong results file (date of first line is invalid")
235 << QStringLiteral("WrongDate.txt")
275 << QStringLiteral("WrongDate.txt")
236 << ExpectedResults<ScalarSeries>{}
276 << ExpectedResults<ScalarSeries>{}
237 .setParsingOK(true)
277 .setParsingOK(true)
238 .setXAxisUnit(Unit{"nT", true})
278 .setXAxisUnit(Unit{"nT", true})
239 .setXAxisData({dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)})
279 .setXAxisData({dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)})
240 .setValuesData({-2.71850, -2.52150});
280 .setValuesData({-2.71850, -2.52150});
241
281
242 QTest::newRow("Wrong results file (too many values for first line")
282 QTest::newRow("Wrong results file (too many values for first line")
243 << QStringLiteral("TooManyValues.txt")
283 << QStringLiteral("TooManyValues.txt")
244 << ExpectedResults<ScalarSeries>{}
284 << ExpectedResults<ScalarSeries>{}
245 .setParsingOK(true)
285 .setParsingOK(true)
246 .setXAxisUnit(Unit{"nT", true})
286 .setXAxisUnit(Unit{"nT", true})
247 .setXAxisData({dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)})
287 .setXAxisData({dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)})
248 .setValuesData({-2.71850, -2.52150});
288 .setValuesData({-2.71850, -2.52150});
249
289
250 QTest::newRow("Wrong results file (x of first line is NaN")
290 QTest::newRow("Wrong results file (x of first line is NaN")
251 << QStringLiteral("NaNX.txt")
291 << QStringLiteral("NaNX.txt")
252 << ExpectedResults<ScalarSeries>{}
292 << ExpectedResults<ScalarSeries>{}
253 .setParsingOK(true)
293 .setParsingOK(true)
254 .setXAxisUnit(Unit{"nT", true})
294 .setXAxisUnit(Unit{"nT", true})
255 .setXAxisData({dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)})
295 .setXAxisData({dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)})
256 .setValuesData({-2.71850, -2.52150});
296 .setValuesData({-2.71850, -2.52150});
257
297
258 QTest::newRow("Invalid file type (vector)")
298 QTest::newRow("Invalid file type (vector)")
259 << QStringLiteral("ValidVector1.txt")
299 << QStringLiteral("ValidVector1.txt")
260 << ExpectedResults<ScalarSeries>{}.setParsingOK(true).setXAxisUnit(Unit{"nT", true});
300 << ExpectedResults<ScalarSeries>{}.setParsingOK(true).setXAxisUnit(Unit{"nT", true});
261
301
262 // Invalid files
302 // Invalid files
263 QTest::newRow("Invalid file (unexisting file)")
303 QTest::newRow("Invalid file (unexisting file)")
264 << QStringLiteral("UnexistingFile.txt")
304 << QStringLiteral("UnexistingFile.txt")
265 << ExpectedResults<ScalarSeries>{}.setParsingOK(false);
305 << ExpectedResults<ScalarSeries>{}.setParsingOK(false);
266
306
267 QTest::newRow("Invalid file (file not found on server)")
307 QTest::newRow("Invalid file (file not found on server)")
268 << QStringLiteral("FileNotFound.txt")
308 << QStringLiteral("FileNotFound.txt")
269 << ExpectedResults<ScalarSeries>{}.setParsingOK(false);
309 << ExpectedResults<ScalarSeries>{}.setParsingOK(false);
270 }
310 }
271
311
272 void TestAmdaResultParser::testReadScalarTxt()
312 void TestAmdaResultParser::testReadScalarTxt()
273 {
313 {
274 testRead<ScalarSeries>(AmdaResultParser::ValueType::SCALAR);
314 testRead<ScalarSeries>(AmdaResultParser::ValueType::SCALAR);
275 }
315 }
276
316
277 void TestAmdaResultParser::testReadVectorTxt_data()
317 void TestAmdaResultParser::testReadVectorTxt_data()
278 {
318 {
279 testReadDataStructure<VectorSeries>();
319 testReadDataStructure<VectorSeries>();
280
320
281 // ////////// //
321 // ////////// //
282 // Test cases //
322 // Test cases //
283 // ////////// //
323 // ////////// //
284
324
285 // Valid files
325 // Valid files
286 QTest::newRow("Valid file")
326 QTest::newRow("Valid file")
287 << QStringLiteral("ValidVector1.txt")
327 << QStringLiteral("ValidVector1.txt")
288 << ExpectedResults<VectorSeries>{}
328 << ExpectedResults<VectorSeries>{}
289 .setParsingOK(true)
329 .setParsingOK(true)
290 .setXAxisUnit(Unit{"nT", true})
330 .setXAxisUnit(Unit{"nT", true})
291 .setXAxisData({dateTime(2013, 7, 2, 9, 13, 50), dateTime(2013, 7, 2, 9, 14, 6),
331 .setXAxisData({dateTime(2013, 7, 2, 9, 13, 50), dateTime(2013, 7, 2, 9, 14, 6),
292 dateTime(2013, 7, 2, 9, 14, 22), dateTime(2013, 7, 2, 9, 14, 38),
332 dateTime(2013, 7, 2, 9, 14, 22), dateTime(2013, 7, 2, 9, 14, 38),
293 dateTime(2013, 7, 2, 9, 14, 54), dateTime(2013, 7, 2, 9, 15, 10),
333 dateTime(2013, 7, 2, 9, 14, 54), dateTime(2013, 7, 2, 9, 15, 10),
294 dateTime(2013, 7, 2, 9, 15, 26), dateTime(2013, 7, 2, 9, 15, 42),
334 dateTime(2013, 7, 2, 9, 15, 26), dateTime(2013, 7, 2, 9, 15, 42),
295 dateTime(2013, 7, 2, 9, 15, 58), dateTime(2013, 7, 2, 9, 16, 14)})
335 dateTime(2013, 7, 2, 9, 15, 58), dateTime(2013, 7, 2, 9, 16, 14)})
296 .setValuesData(
336 .setValuesData(
297 {{-0.332, -1.011, -1.457, -1.293, -1.217, -1.443, -1.278, -1.202, -1.22, -1.259},
337 {{-0.332, -1.011, -1.457, -1.293, -1.217, -1.443, -1.278, -1.202, -1.22, -1.259},
298 {3.206, 2.999, 2.785, 2.736, 2.612, 2.564, 2.892, 2.862, 2.859, 2.764},
338 {3.206, 2.999, 2.785, 2.736, 2.612, 2.564, 2.892, 2.862, 2.859, 2.764},
299 {0.058, 0.496, 1.018, 1.485, 1.662, 1.505, 1.168, 1.244, 1.15, 1.358}});
339 {0.058, 0.496, 1.018, 1.485, 1.662, 1.505, 1.168, 1.244, 1.15, 1.358}});
300
340
301 // Valid files but with some invalid lines (wrong unit, wrong values, etc.)
341 // Valid files but with some invalid lines (wrong unit, wrong values, etc.)
302 QTest::newRow("Invalid file type (scalar)")
342 QTest::newRow("Invalid file type (scalar)")
303 << QStringLiteral("ValidScalar1.txt")
343 << QStringLiteral("ValidScalar1.txt")
304 << ExpectedResults<VectorSeries>{}
344 << ExpectedResults<VectorSeries>{}
305 .setParsingOK(true)
345 .setParsingOK(true)
306 .setXAxisUnit(Unit{"nT", true})
346 .setXAxisUnit(Unit{"nT", true})
307 .setXAxisData({})
347 .setXAxisData({})
308 .setValuesData(QVector<QVector<double> >{{}, {}, {}});
348 .setValuesData(QVector<QVector<double> >{{}, {}, {}});
309 }
349 }
310
350
311 void TestAmdaResultParser::testReadVectorTxt()
351 void TestAmdaResultParser::testReadVectorTxt()
312 {
352 {
313 testRead<VectorSeries>(AmdaResultParser::ValueType::VECTOR);
353 testRead<VectorSeries>(AmdaResultParser::ValueType::VECTOR);
314 }
354 }
315
355
316 QTEST_MAIN(TestAmdaResultParser)
356 QTEST_MAIN(TestAmdaResultParser)
317 #include "TestAmdaResultParser.moc"
357 #include "TestAmdaResultParser.moc"
General Comments 0
You need to be logged in to leave comments. Login now