##// END OF EJS Templates
Handles y-axis in the unit tests...
Alexandre Leroux -
r969:299bc9e2c2bd
parent child
Show More
@@ -67,6 +67,24 struct ExpectedResults {
67 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 89 * Validates a DataSeries compared to the expected results
72 90 * @param results the DataSeries to validate
@@ -106,6 +124,22 struct ExpectedResults {
106 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 144 else {
111 145 QVERIFY(results == nullptr);
@@ -122,6 +156,12 struct ExpectedResults {
122 156 Unit m_ValuesUnit{};
123 157 // Expected values data
124 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 167 } // namespace
General Comments 0
You need to be logged in to leave comments. Login now