From 299bc9e2c2bd67ab8246f02fa4a3cf5896ddcc37 2017-11-22 16:47:11 From: Alexandre Leroux Date: 2017-11-22 16:47:11 Subject: [PATCH] Handles y-axis in the unit tests For data series that handle y-axis (like spectrograms), adds verifications on it --- diff --git a/plugins/amda/tests/TestAmdaResultParser.cpp b/plugins/amda/tests/TestAmdaResultParser.cpp index 48e30b3..062085b 100644 --- a/plugins/amda/tests/TestAmdaResultParser.cpp +++ b/plugins/amda/tests/TestAmdaResultParser.cpp @@ -67,6 +67,24 @@ struct ExpectedResults { return *this; } + ExpectedResults &setYAxisEnabled(bool yAxisEnabled) + { + m_YAxisEnabled = yAxisEnabled; + return *this; + } + + ExpectedResults &setYAxisUnit(Unit yAxisUnit) + { + m_YAxisUnit = std::move(yAxisUnit); + return *this; + } + + ExpectedResults &setYAxisData(QVector yAxisData) + { + m_YAxisData = std::move(yAxisData); + return *this; + } + /** * Validates a DataSeries compared to the expected results * @param results the DataSeries to validate @@ -106,6 +124,22 @@ struct ExpectedResults { return (std::isnan(itValue) && std::isnan(value)) || seriesIt.value(i) == value; }); } + + // Checks y-axis (if defined) + auto yAxis = dataSeries->yAxis(); + QCOMPARE(yAxis.isDefined(), m_YAxisEnabled); + + if (m_YAxisEnabled) { + // Unit + QCOMPARE(yAxis.unit(), m_YAxisUnit); + + // Data + auto yAxisSize = yAxis.size(); + QCOMPARE(yAxisSize, m_YAxisData.size()); + for (auto i = 0; i < yAxisSize; ++i) { + QCOMPARE(yAxis.at(i), m_YAxisData.at(i)); + } + } } else { QVERIFY(results == nullptr); @@ -122,6 +156,12 @@ struct ExpectedResults { Unit m_ValuesUnit{}; // Expected values data QVector > m_ValuesData{}; + // Expected data series has y-axis + bool m_YAxisEnabled{false}; + // Expected y-axis unit (if axis defined) + Unit m_YAxisUnit{}; + // Expected y-axis data (if axis defined) + QVector m_YAxisData{}; }; } // namespace