Mercurial > hg > svcore
comparison data/fileio/test/CSVReaderTest.h @ 1875:f49afb5b9eac
Fix comparisons that fail to link with older Qt libraries
author | Chris Cannam |
---|---|
date | Thu, 18 Jun 2020 15:07:40 +0100 |
parents | 1d44fdc8196c |
children | 9a288b9b7a72 |
comparison
equal
deleted
inserted
replaced
1874:48f50a4a82ea | 1875:f49afb5b9eac |
---|---|
74 void modelType1DSamples() { | 74 void modelType1DSamples() { |
75 Model *model = nullptr; | 75 Model *model = nullptr; |
76 loadFrom("model-type-1d-samples.csv", model); | 76 loadFrom("model-type-1d-samples.csv", model); |
77 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); | 77 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); |
78 QVERIFY(actual); | 78 QVERIFY(actual); |
79 QCOMPARE(actual->getAllEvents().size(), 5); | 79 QCOMPARE(int(actual->getAllEvents().size()), 5); |
80 vector<sv_frame_t> expected { 45678, 123239, 320130, 452103, 620301 }; | 80 vector<sv_frame_t> expected { 45678, 123239, 320130, 452103, 620301 }; |
81 for (int i = 0; in_range_for(expected, i); ++i) { | 81 for (int i = 0; in_range_for(expected, i); ++i) { |
82 QCOMPARE(actual->getAllEvents()[i], Event(expected[i])); | 82 QCOMPARE(actual->getAllEvents()[i], Event(expected[i])); |
83 } | 83 } |
84 delete model; | 84 delete model; |
87 void modelType1DSamplesWithHeader() { | 87 void modelType1DSamplesWithHeader() { |
88 Model *model = nullptr; | 88 Model *model = nullptr; |
89 loadFrom("model-type-1d-samples-header.csv", model); | 89 loadFrom("model-type-1d-samples-header.csv", model); |
90 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); | 90 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); |
91 QVERIFY(actual); | 91 QVERIFY(actual); |
92 QCOMPARE(actual->getAllEvents().size(), 5); | 92 QCOMPARE(int(actual->getAllEvents().size()), 5); |
93 vector<sv_frame_t> expected { 45678, 123239, 320130, 452103, 620301 }; | 93 vector<sv_frame_t> expected { 45678, 123239, 320130, 452103, 620301 }; |
94 for (int i = 0; in_range_for(expected, i); ++i) { | 94 for (int i = 0; in_range_for(expected, i); ++i) { |
95 QCOMPARE(actual->getAllEvents()[i], Event(expected[i])); | 95 QCOMPARE(actual->getAllEvents()[i], Event(expected[i])); |
96 } | 96 } |
97 delete model; | 97 delete model; |
100 void modelType1DSeconds() { | 100 void modelType1DSeconds() { |
101 Model *model = nullptr; | 101 Model *model = nullptr; |
102 loadFrom("model-type-1d-seconds.csv", model); | 102 loadFrom("model-type-1d-seconds.csv", model); |
103 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); | 103 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); |
104 QVERIFY(actual); | 104 QVERIFY(actual); |
105 QCOMPARE(actual->getAllEvents().size(), 5); | 105 QCOMPARE(int(actual->getAllEvents().size()), 5); |
106 delete model; | 106 delete model; |
107 } | 107 } |
108 | 108 |
109 void modelType1DSecondsWithHeader() { | 109 void modelType1DSecondsWithHeader() { |
110 Model *model = nullptr; | 110 Model *model = nullptr; |
111 loadFrom("model-type-1d-seconds-header.csv", model); | 111 loadFrom("model-type-1d-seconds-header.csv", model); |
112 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); | 112 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); |
113 QVERIFY(actual); | 113 QVERIFY(actual); |
114 QCOMPARE(actual->getAllEvents().size(), 5); | 114 QCOMPARE(int(actual->getAllEvents().size()), 5); |
115 delete model; | 115 delete model; |
116 } | 116 } |
117 | 117 |
118 void modelType2DDurationSamples() { | 118 void modelType2DDurationSamples() { |
119 Model *model = nullptr; | 119 Model *model = nullptr; |
120 loadFrom("model-type-2d-duration-samples.csv", model); | 120 loadFrom("model-type-2d-duration-samples.csv", model); |
121 auto actual = qobject_cast<RegionModel *>(model); | 121 auto actual = qobject_cast<RegionModel *>(model); |
122 QVERIFY(actual); | 122 QVERIFY(actual); |
123 QCOMPARE(actual->getAllEvents().size(), 5); | 123 QCOMPARE((actual->getAllEvents().size()), 5); |
124 delete model; | 124 delete model; |
125 } | 125 } |
126 | 126 |
127 void modelType2DDurationSamplesWithHeader() { | 127 void modelType2DDurationSamplesWithHeader() { |
128 Model *model = nullptr; | 128 Model *model = nullptr; |
129 loadFrom("model-type-2d-duration-samples-header.csv", model); | 129 loadFrom("model-type-2d-duration-samples-header.csv", model); |
130 auto actual = qobject_cast<RegionModel *>(model); | 130 auto actual = qobject_cast<RegionModel *>(model); |
131 QVERIFY(actual); | 131 QVERIFY(actual); |
132 QCOMPARE(actual->getAllEvents().size(), 5); | 132 QCOMPARE(int(actual->getAllEvents().size()), 5); |
133 delete model; | 133 delete model; |
134 } | 134 } |
135 | 135 |
136 void modelType2DDurationSeconds() { | 136 void modelType2DDurationSeconds() { |
137 Model *model = nullptr; | 137 Model *model = nullptr; |
138 loadFrom("model-type-2d-duration-seconds.csv", model); | 138 loadFrom("model-type-2d-duration-seconds.csv", model); |
139 auto actual = qobject_cast<RegionModel *>(model); | 139 auto actual = qobject_cast<RegionModel *>(model); |
140 QVERIFY(actual); | 140 QVERIFY(actual); |
141 QCOMPARE(actual->getAllEvents().size(), 5); | 141 QCOMPARE(int(actual->getAllEvents().size()), 5); |
142 delete model; | 142 delete model; |
143 } | 143 } |
144 | 144 |
145 void modelType2DDurationSecondsWithHeader() { | 145 void modelType2DDurationSecondsWithHeader() { |
146 Model *model = nullptr; | 146 Model *model = nullptr; |
147 loadFrom("model-type-2d-duration-seconds-header.csv", model); | 147 loadFrom("model-type-2d-duration-seconds-header.csv", model); |
148 auto actual = qobject_cast<RegionModel *>(model); | 148 auto actual = qobject_cast<RegionModel *>(model); |
149 QVERIFY(actual); | 149 QVERIFY(actual); |
150 QCOMPARE(actual->getAllEvents().size(), 5); | 150 QCOMPARE(int(actual->getAllEvents().size()), 5); |
151 delete model; | 151 delete model; |
152 } | 152 } |
153 | 153 |
154 void badNegativeDuration() { | 154 void badNegativeDuration() { |
155 Model *model = nullptr; | 155 Model *model = nullptr; |
156 loadFrom("bad-negative-duration.csv", model); | 156 loadFrom("bad-negative-duration.csv", model); |
157 auto actual = qobject_cast<RegionModel *>(model); | 157 auto actual = qobject_cast<RegionModel *>(model); |
158 QVERIFY(actual); | 158 QVERIFY(actual); |
159 //!!! + check duration has been corrected | 159 //!!! + check duration has been corrected |
160 QCOMPARE(actual->getAllEvents().size(), 5); | 160 QCOMPARE(int(actual->getAllEvents().size()), 5); |
161 delete model; | 161 delete model; |
162 } | 162 } |
163 | 163 |
164 void modelType2DEndTimeSamples() { | 164 void modelType2DEndTimeSamples() { |
165 Model *model = nullptr; | 165 Model *model = nullptr; |
166 loadFrom("model-type-2d-endtime-samples.csv", model); | 166 loadFrom("model-type-2d-endtime-samples.csv", model); |
167 auto actual = qobject_cast<RegionModel *>(model); | 167 auto actual = qobject_cast<RegionModel *>(model); |
168 QVERIFY(actual); | 168 QVERIFY(actual); |
169 QCOMPARE(actual->getAllEvents().size(), 5); | 169 QCOMPARE(int(actual->getAllEvents().size()), 5); |
170 delete model; | 170 delete model; |
171 } | 171 } |
172 | 172 |
173 void modelType2DEndTimeSamplesWithHeader() { | 173 void modelType2DEndTimeSamplesWithHeader() { |
174 Model *model = nullptr; | 174 Model *model = nullptr; |
175 loadFrom("model-type-2d-endtime-samples-header.csv", model); | 175 loadFrom("model-type-2d-endtime-samples-header.csv", model); |
176 auto actual = qobject_cast<RegionModel *>(model); | 176 auto actual = qobject_cast<RegionModel *>(model); |
177 QVERIFY(actual); | 177 QVERIFY(actual); |
178 QCOMPARE(actual->getAllEvents().size(), 5); | 178 QCOMPARE(int(actual->getAllEvents().size()), 5); |
179 delete model; | 179 delete model; |
180 } | 180 } |
181 | 181 |
182 void modelType2DEndTimeSeconds() { | 182 void modelType2DEndTimeSeconds() { |
183 Model *model = nullptr; | 183 Model *model = nullptr; |
184 loadFrom("model-type-2d-endtime-seconds.csv", model); | 184 loadFrom("model-type-2d-endtime-seconds.csv", model); |
185 auto actual = qobject_cast<RegionModel *>(model); | 185 auto actual = qobject_cast<RegionModel *>(model); |
186 QVERIFY(actual); | 186 QVERIFY(actual); |
187 QCOMPARE(actual->getAllEvents().size(), 5); | 187 QCOMPARE(int(actual->getAllEvents().size()), 5); |
188 delete model; | 188 delete model; |
189 } | 189 } |
190 | 190 |
191 void modelType2DEndTimeSecondsWithHeader() { | 191 void modelType2DEndTimeSecondsWithHeader() { |
192 Model *model = nullptr; | 192 Model *model = nullptr; |
193 loadFrom("model-type-2d-endtime-seconds-header.csv", model); | 193 loadFrom("model-type-2d-endtime-seconds-header.csv", model); |
194 auto actual = qobject_cast<RegionModel *>(model); | 194 auto actual = qobject_cast<RegionModel *>(model); |
195 QVERIFY(actual); | 195 QVERIFY(actual); |
196 QCOMPARE(actual->getAllEvents().size(), 5); | 196 QCOMPARE(int(actual->getAllEvents().size()), 5); |
197 delete model; | 197 delete model; |
198 } | 198 } |
199 | 199 |
200 void modelType2DImplicit() { | 200 void modelType2DImplicit() { |
201 Model *model = nullptr; | 201 Model *model = nullptr; |
202 loadFrom("model-type-2d-implicit.csv", model); | 202 loadFrom("model-type-2d-implicit.csv", model); |
203 auto actual = qobject_cast<SparseTimeValueModel *>(model); | 203 auto actual = qobject_cast<SparseTimeValueModel *>(model); |
204 QVERIFY(actual); | 204 QVERIFY(actual); |
205 QCOMPARE(actual->getAllEvents().size(), 5); | 205 QCOMPARE(int(actual->getAllEvents().size()), 5); |
206 vector<sv_frame_t> expectedFrames { 0, 1024, 2048, 3072, 4096 }; | 206 vector<sv_frame_t> expectedFrames { 0, 1024, 2048, 3072, 4096 }; |
207 vector<float> expectedValues { 4.f, 4.2f, 0.4f, 3.8f, -2.3f }; | 207 vector<float> expectedValues { 4.f, 4.2f, 0.4f, 3.8f, -2.3f }; |
208 vector<QString> expectedLabels { {}, {}, "A label", {}, {} }; | 208 vector<QString> expectedLabels { {}, {}, "A label", {}, {} }; |
209 for (int i = 0; in_range_for(expectedFrames, i); ++i) { | 209 for (int i = 0; in_range_for(expectedFrames, i); ++i) { |
210 QCOMPARE(actual->getAllEvents()[i], | 210 QCOMPARE(actual->getAllEvents()[i], |
218 void modelType2DImplicitWithHeader() { | 218 void modelType2DImplicitWithHeader() { |
219 Model *model = nullptr; | 219 Model *model = nullptr; |
220 loadFrom("model-type-2d-implicit-header.csv", model); | 220 loadFrom("model-type-2d-implicit-header.csv", model); |
221 auto actual = qobject_cast<SparseTimeValueModel *>(model); | 221 auto actual = qobject_cast<SparseTimeValueModel *>(model); |
222 QVERIFY(actual); | 222 QVERIFY(actual); |
223 QCOMPARE(actual->getAllEvents().size(), 5); | 223 QCOMPARE(int(actual->getAllEvents().size()), 5); |
224 vector<sv_frame_t> expectedFrames { 0, 1024, 2048, 3072, 4096 }; | 224 vector<sv_frame_t> expectedFrames { 0, 1024, 2048, 3072, 4096 }; |
225 vector<float> expectedValues { 4.f, 4.2f, 0.4f, 3.8f, -2.3f }; | 225 vector<float> expectedValues { 4.f, 4.2f, 0.4f, 3.8f, -2.3f }; |
226 vector<QString> expectedLabels { {}, {}, "A label", {}, {} }; | 226 vector<QString> expectedLabels { {}, {}, "A label", {}, {} }; |
227 for (int i = 0; in_range_for(expectedFrames, i); ++i) { | 227 for (int i = 0; in_range_for(expectedFrames, i); ++i) { |
228 QCOMPARE(actual->getAllEvents()[i], | 228 QCOMPARE(actual->getAllEvents()[i], |
236 void modelType2DSamples() { | 236 void modelType2DSamples() { |
237 Model *model = nullptr; | 237 Model *model = nullptr; |
238 loadFrom("model-type-2d-samples.csv", model); | 238 loadFrom("model-type-2d-samples.csv", model); |
239 auto actual = qobject_cast<SparseTimeValueModel *>(model); | 239 auto actual = qobject_cast<SparseTimeValueModel *>(model); |
240 QVERIFY(actual); | 240 QVERIFY(actual); |
241 QCOMPARE(actual->getAllEvents().size(), 5); | 241 QCOMPARE(int(actual->getAllEvents().size()), 5); |
242 delete model; | 242 delete model; |
243 } | 243 } |
244 | 244 |
245 void modelType2DSamplesWithHeader() { | 245 void modelType2DSamplesWithHeader() { |
246 Model *model = nullptr; | 246 Model *model = nullptr; |
247 loadFrom("model-type-2d-samples-header.csv", model); | 247 loadFrom("model-type-2d-samples-header.csv", model); |
248 auto actual = qobject_cast<SparseTimeValueModel *>(model); | 248 auto actual = qobject_cast<SparseTimeValueModel *>(model); |
249 QVERIFY(actual); | 249 QVERIFY(actual); |
250 QCOMPARE(actual->getAllEvents().size(), 5); | 250 QCOMPARE(int(actual->getAllEvents().size()), 5); |
251 delete model; | 251 delete model; |
252 } | 252 } |
253 | 253 |
254 void modelType2DSeconds() { | 254 void modelType2DSeconds() { |
255 Model *model = nullptr; | 255 Model *model = nullptr; |
256 loadFrom("model-type-2d-seconds.csv", model); | 256 loadFrom("model-type-2d-seconds.csv", model); |
257 auto actual = qobject_cast<SparseTimeValueModel *>(model); | 257 auto actual = qobject_cast<SparseTimeValueModel *>(model); |
258 QVERIFY(actual); | 258 QVERIFY(actual); |
259 QCOMPARE(actual->getAllEvents().size(), 5); | 259 QCOMPARE(int(actual->getAllEvents().size()), 5); |
260 delete model; | 260 delete model; |
261 } | 261 } |
262 | 262 |
263 void modelType2DSecondsWithHeader() { | 263 void modelType2DSecondsWithHeader() { |
264 Model *model = nullptr; | 264 Model *model = nullptr; |
265 loadFrom("model-type-2d-seconds-header.csv", model); | 265 loadFrom("model-type-2d-seconds-header.csv", model); |
266 auto actual = qobject_cast<SparseTimeValueModel *>(model); | 266 auto actual = qobject_cast<SparseTimeValueModel *>(model); |
267 QVERIFY(actual); | 267 QVERIFY(actual); |
268 QCOMPARE(actual->getAllEvents().size(), 5); | 268 QCOMPARE(int(actual->getAllEvents().size()), 5); |
269 delete model; | 269 delete model; |
270 } | 270 } |
271 | 271 |
272 void modelType3DImplicit() { | 272 void modelType3DImplicit() { |
273 Model *model = nullptr; | 273 Model *model = nullptr; |
332 void withBlankLines1D() { | 332 void withBlankLines1D() { |
333 Model *model = nullptr; | 333 Model *model = nullptr; |
334 loadFrom("with-blank-lines-1d.csv", model); | 334 loadFrom("with-blank-lines-1d.csv", model); |
335 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); | 335 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); |
336 QVERIFY(actual); | 336 QVERIFY(actual); |
337 QCOMPARE(actual->getAllEvents().size(), 5); | 337 QCOMPARE(int(actual->getAllEvents().size()), 5); |
338 delete model; | 338 delete model; |
339 } | 339 } |
340 | 340 |
341 void withBlankLines2D() { | 341 void withBlankLines2D() { |
342 Model *model = nullptr; | 342 Model *model = nullptr; |
343 loadFrom("with-blank-lines-2d.csv", model); | 343 loadFrom("with-blank-lines-2d.csv", model); |
344 auto actual = qobject_cast<SparseTimeValueModel *>(model); | 344 auto actual = qobject_cast<SparseTimeValueModel *>(model); |
345 QVERIFY(actual); | 345 QVERIFY(actual); |
346 QCOMPARE(actual->getAllEvents().size(), 5); | 346 QCOMPARE(int(actual->getAllEvents().size()), 5); |
347 delete model; | 347 delete model; |
348 } | 348 } |
349 | 349 |
350 void withBlankLines3D() { | 350 void withBlankLines3D() { |
351 Model *model = nullptr; | 351 Model *model = nullptr; |
360 void quoting() { | 360 void quoting() { |
361 Model *model = nullptr; | 361 Model *model = nullptr; |
362 loadFrom("quoting.csv", model); | 362 loadFrom("quoting.csv", model); |
363 auto actual = qobject_cast<SparseTimeValueModel *>(model); | 363 auto actual = qobject_cast<SparseTimeValueModel *>(model); |
364 QVERIFY(actual); | 364 QVERIFY(actual); |
365 QCOMPARE(actual->getAllEvents().size(), 5); | 365 QCOMPARE(int(actual->getAllEvents().size()), 5); |
366 delete model; | 366 delete model; |
367 } | 367 } |
368 }; | 368 }; |
369 | 369 |
370 #endif | 370 #endif |