comparison data/fileio/test/CSVFormatTest.h @ 1870:1b8c4ee06f6d csv-import-headers

Detect presence of header row in CSV format guesser; use headings to inform our guesses about column purposes; test this
author Chris Cannam
date Wed, 17 Jun 2020 18:01:00 +0100
parents 9570ef94eaa3
children 1d44fdc8196c
comparison
equal deleted inserted replaced
1868:44dba7cd9ec3 1870:1b8c4ee06f6d
103 QCOMPARE(actual, p); 103 QCOMPARE(actual, p);
104 } 104 }
105 105
106 void comment() { 106 void comment() {
107 CSVFormat f; 107 CSVFormat f;
108 f.setHeaderStatus(CSVFormat::HeaderAbsent);
108 QVERIFY(f.guessFormatFor(csvDir.filePath("comment.csv"))); 109 QVERIFY(f.guessFormatFor(csvDir.filePath("comment.csv")));
109 QCOMPARE(f.getSeparator(), QChar(',')); 110 QCOMPARE(f.getSeparator(), QChar(','));
110 QCOMPARE(f.getColumnCount(), 4); 111 QCOMPARE(f.getColumnCount(), 4);
111 } 112 }
112 113
140 141
141 void modelType1DSamples() { 142 void modelType1DSamples() {
142 CSVFormat f; 143 CSVFormat f;
143 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-samples.csv"))); 144 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-samples.csv")));
144 QCOMPARE(f.getColumnCount(), 1); 145 QCOMPARE(f.getColumnCount(), 1);
146 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
145 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); 147 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
146 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); 148 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
147 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); 149 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
148 QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel); 150 QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel);
149 } 151 }
150 152
153 void modelType1DSamplesWithHeader() {
154 CSVFormat f;
155 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-samples-header.csv")));
156 QCOMPARE(f.getColumnCount(), 1);
157 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
158 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
159 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
160 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
161 QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel);
162 }
163
151 void modelType1DSeconds() { 164 void modelType1DSeconds() {
152 CSVFormat f; 165 CSVFormat f;
153 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-seconds.csv"))); 166 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-seconds.csv")));
154 QCOMPARE(f.getColumnCount(), 2); 167 QCOMPARE(f.getColumnCount(), 2);
168 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
155 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); 169 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
156 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnLabel); 170 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnLabel);
157 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); 171 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
158 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); 172 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
159 QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel); 173 QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel);
160 } 174 }
161 175
176 void modelType1DSecondsWithHeader() {
177 CSVFormat f;
178 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-seconds-header.csv")));
179 QCOMPARE(f.getColumnCount(), 2);
180 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
181 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
182 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnLabel);
183 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
184 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
185 QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel);
186 }
187
162 void modelType2DSamples() { 188 void modelType2DSamples() {
163 CSVFormat f; 189 CSVFormat f;
164 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-samples.csv"))); 190 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-samples.csv")));
165 QCOMPARE(f.getColumnCount(), 2); 191 QCOMPARE(f.getColumnCount(), 2);
192 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
193 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
194 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
195 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
196 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
197 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel);
198 }
199
200 void modelType2DSamplesWithHeader() {
201 CSVFormat f;
202 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-samples-header.csv")));
203 QCOMPARE(f.getColumnCount(), 2);
204 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
166 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); 205 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
167 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); 206 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
168 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); 207 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
169 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); 208 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
170 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel); 209 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel);
172 211
173 void modelType2DSeconds() { 212 void modelType2DSeconds() {
174 CSVFormat f; 213 CSVFormat f;
175 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-seconds.csv"))); 214 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-seconds.csv")));
176 QCOMPARE(f.getColumnCount(), 2); 215 QCOMPARE(f.getColumnCount(), 2);
216 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
217 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
218 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
219 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
220 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
221 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel);
222 }
223
224 void modelType2DSecondsWithHeader() {
225 CSVFormat f;
226 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-seconds-header.csv")));
227 QCOMPARE(f.getColumnCount(), 2);
228 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
177 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); 229 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
178 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); 230 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
179 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); 231 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
180 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); 232 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
181 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel); 233 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel);
183 235
184 void modelType2DImplicit() { 236 void modelType2DImplicit() {
185 CSVFormat f; 237 CSVFormat f;
186 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-implicit.csv"))); 238 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-implicit.csv")));
187 QCOMPARE(f.getColumnCount(), 1); 239 QCOMPARE(f.getColumnCount(), 1);
240 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
188 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue); 241 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue);
189 QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming); 242 QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming);
190 } 243 }
191 244
245 void modelType2DImplicitWithHeader() {
246 CSVFormat f;
247 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-implicit-header.csv")));
248 QCOMPARE(f.getColumnCount(), 2);
249 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
250 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue);
251 QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming);
252 }
253
192 void modelType2DEndTimeSamples() { 254 void modelType2DEndTimeSamples() {
193 CSVFormat f; 255 CSVFormat f;
194 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-samples.csv"))); 256 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-samples.csv")));
195 QCOMPARE(f.getColumnCount(), 3); 257 QCOMPARE(f.getColumnCount(), 3);
258 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
196 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); 259 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
197 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnEndTime); 260 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnEndTime);
198 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); 261 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
199 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); 262 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
200 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); 263 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
201 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration); 264 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
202 } 265 }
203 266
267 void modelType2DEndTimeSamplesWithHeader() {
268 CSVFormat f;
269 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-samples-header.csv")));
270 QCOMPARE(f.getColumnCount(), 3);
271 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
272 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
273 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
274 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnEndTime);
275 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
276 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
277 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
278 }
279
204 void modelType2DEndTimeSeconds() { 280 void modelType2DEndTimeSeconds() {
205 CSVFormat f; 281 CSVFormat f;
206 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-seconds.csv"))); 282 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-seconds.csv")));
207 QCOMPARE(f.getColumnCount(), 3); 283 QCOMPARE(f.getColumnCount(), 3);
284 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
208 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); 285 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
209 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnEndTime); 286 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnEndTime);
210 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); 287 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
211 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); 288 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
212 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); 289 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
213 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration); 290 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
214 } 291 }
215 292
293 void modelType2DEndTimeSecondsWithHeader() {
294 CSVFormat f;
295 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-seconds-header.csv")));
296 QCOMPARE(f.getColumnCount(), 3);
297 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
298 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
299 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
300 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnEndTime);
301 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
302 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
303 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
304 }
305
216 void modelType2DDurationSamples() { 306 void modelType2DDurationSamples() {
217 CSVFormat f; 307 CSVFormat f;
218 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-samples.csv"))); 308 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-samples.csv")));
219 QCOMPARE(f.getColumnCount(), 3); 309 QCOMPARE(f.getColumnCount(), 3);
310 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
220 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); 311 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
221 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnDuration); 312 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnDuration);
222 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); 313 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
314 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
315 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
316 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
317 }
318
319 void modelType2DDurationSamplesWithHeader() {
320 CSVFormat f;
321 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-samples-header.csv")));
322 QCOMPARE(f.getColumnCount(), 3);
323 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
324 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
325 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
326 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnDuration);
223 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); 327 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
224 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); 328 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
225 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration); 329 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
226 } 330 }
227 331
228 void modelType2DDurationSeconds() { 332 void modelType2DDurationSeconds() {
229 CSVFormat f; 333 CSVFormat f;
230 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-seconds.csv"))); 334 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-seconds.csv")));
231 QCOMPARE(f.getColumnCount(), 3); 335 QCOMPARE(f.getColumnCount(), 3);
336 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
232 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); 337 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
233 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnDuration); 338 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnDuration);
234 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); 339 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
340 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
341 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
342 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
343 }
344
345 void modelType2DDurationSecondsWithHeader() {
346 CSVFormat f;
347 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-seconds-header.csv")));
348 QCOMPARE(f.getColumnCount(), 3);
349 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
350 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
351 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
352 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnDuration);
235 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); 353 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
236 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); 354 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
237 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration); 355 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
238 } 356 }
239 357
240 void modelType3DSamples() { 358 void modelType3DSamples() {
241 CSVFormat f; 359 CSVFormat f;
242 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-samples.csv"))); 360 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-samples.csv")));
243 QCOMPARE(f.getColumnCount(), 7); 361 QCOMPARE(f.getColumnCount(), 7);
362 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
363 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
364 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
365 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
366 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue);
367 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue);
368 QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue);
369 QCOMPARE(f.getColumnPurpose(6), CSVFormat::ColumnValue);
370 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
371 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
372 QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel);
373 }
374
375 void modelType3DSamplesWithHeader() {
376 CSVFormat f;
377 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-samples-header.csv")));
378 QCOMPARE(f.getColumnCount(), 7);
379 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
244 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); 380 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
245 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); 381 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
246 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); 382 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
247 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue); 383 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue);
248 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue); 384 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue);
255 391
256 void modelType3DSeconds() { 392 void modelType3DSeconds() {
257 CSVFormat f; 393 CSVFormat f;
258 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-seconds.csv"))); 394 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-seconds.csv")));
259 QCOMPARE(f.getColumnCount(), 7); 395 QCOMPARE(f.getColumnCount(), 7);
396 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
397 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
398 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
399 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
400 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue);
401 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue);
402 QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue);
403 QCOMPARE(f.getColumnPurpose(6), CSVFormat::ColumnValue);
404 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
405 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
406 QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel);
407 }
408
409 void modelType3DSecondsWithHeader() {
410 CSVFormat f;
411 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-seconds-header.csv")));
412 QCOMPARE(f.getColumnCount(), 7);
413 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
260 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); 414 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
261 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); 415 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
262 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); 416 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
263 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue); 417 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue);
264 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue); 418 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue);
271 425
272 void modelType3DImplicit() { 426 void modelType3DImplicit() {
273 CSVFormat f; 427 CSVFormat f;
274 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-implicit.csv"))); 428 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-implicit.csv")));
275 QCOMPARE(f.getColumnCount(), 6); 429 QCOMPARE(f.getColumnCount(), 6);
430 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
431 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue);
432 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
433 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
434 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue);
435 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue);
436 QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue);
437 QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming);
438 QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel);
439 }
440
441 void modelType3DImplicitWithHeader() {
442 CSVFormat f;
443 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-implicit-header.csv")));
444 QCOMPARE(f.getColumnCount(), 6);
445 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
276 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue); 446 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue);
277 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); 447 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
278 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); 448 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
279 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue); 449 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue);
280 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue); 450 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue);