annotate data/fileio/test/CSVFormatTest.h @ 1886:f803d3c33f76 tip

Switch off copious debug in soft synth driving
author Chris Cannam
date Fri, 14 Aug 2020 10:44:44 +0100
parents 1d44fdc8196c
children
rev   line source
Chris@1345 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1345 2
Chris@1345 3 /*
Chris@1345 4 Sonic Visualiser
Chris@1345 5 An audio file viewer and annotation editor.
Chris@1345 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1345 7
Chris@1345 8 This program is free software; you can redistribute it and/or
Chris@1345 9 modify it under the terms of the GNU General Public License as
Chris@1345 10 published by the Free Software Foundation; either version 2 of the
Chris@1345 11 License, or (at your option) any later version. See the file
Chris@1345 12 COPYING included with this distribution for more information.
Chris@1345 13 */
Chris@1345 14
Chris@1524 15 #ifndef TEST_CSV_FORMAT_H
Chris@1524 16 #define TEST_CSV_FORMAT_H
Chris@1345 17
Chris@1524 18 // Tests for the code that guesses the most likely format for parsing a CSV file
Chris@1345 19
Chris@1524 20 #include "../CSVFormat.h"
Chris@1524 21
Chris@1524 22 #include "base/Debug.h"
Chris@1345 23
Chris@1345 24 #include <cmath>
Chris@1345 25
Chris@1345 26 #include <QObject>
Chris@1345 27 #include <QtTest>
Chris@1345 28 #include <QDir>
Chris@1345 29
Chris@1345 30 #include <iostream>
Chris@1345 31
Chris@1345 32 using namespace std;
Chris@1345 33
Chris@1524 34 class CSVFormatTest : public QObject
Chris@1345 35 {
Chris@1345 36 Q_OBJECT
Chris@1345 37
Chris@1346 38 private:
Chris@1524 39 QDir csvDir;
Chris@1346 40
Chris@1346 41 public:
Chris@1524 42 CSVFormatTest(QString base) {
Chris@1346 43 if (base == "") {
Chris@1346 44 base = "svcore/data/fileio/test";
Chris@1346 45 }
Chris@1524 46 csvDir = QDir(base + "/csv");
Chris@1346 47 }
Chris@1346 48
Chris@1524 49 private slots:
Chris@1524 50 void init() {
Chris@1524 51 if (!csvDir.exists()) {
Chris@1524 52 SVCERR << "ERROR: CSV test file directory \"" << csvDir.absolutePath() << "\" does not exist" << endl;
Chris@1524 53 QVERIFY2(csvDir.exists(), "CSV test file directory not found");
Chris@1359 54 }
Chris@1359 55 }
Chris@1359 56
Chris@1524 57 void separatorComma() {
Chris@1524 58 CSVFormat f;
Chris@1524 59 QVERIFY(f.guessFormatFor(csvDir.filePath("separator-comma.csv")));
Chris@1524 60 QCOMPARE(f.getSeparator(), QChar(','));
Chris@1524 61 QCOMPARE(f.getColumnCount(), 3);
Chris@1524 62 }
Chris@1524 63
Chris@1524 64 void separatorTab() {
Chris@1524 65 CSVFormat f;
Chris@1524 66 QVERIFY(f.guessFormatFor(csvDir.filePath("separator-tab.csv")));
Chris@1524 67 QCOMPARE(f.getSeparator(), QChar('\t'));
Chris@1524 68 QCOMPARE(f.getColumnCount(), 3);
Chris@1524 69 }
Chris@1524 70
Chris@1524 71 void separatorPipe() {
Chris@1524 72 CSVFormat f;
Chris@1524 73 QVERIFY(f.guessFormatFor(csvDir.filePath("separator-pipe.csv")));
Chris@1524 74 QCOMPARE(f.getSeparator(), QChar('|'));
Chris@1524 75 // differs from the others
Chris@1524 76 QCOMPARE(f.getColumnCount(), 4);
Chris@1524 77 }
Chris@1524 78
Chris@1524 79 void separatorSpace() {
Chris@1524 80 CSVFormat f;
Chris@1524 81 QVERIFY(f.guessFormatFor(csvDir.filePath("separator-space.csv")));
Chris@1524 82 QCOMPARE(f.getSeparator(), QChar(' '));
Chris@1524 83 // NB fields are separated by 1 or more spaces, not necessarily exactly 1
Chris@1524 84 QCOMPARE(f.getColumnCount(), 3);
Chris@1524 85 }
Chris@1524 86
Chris@1524 87 void separatorColon() {
Chris@1524 88 CSVFormat f;
Chris@1524 89 QVERIFY(f.guessFormatFor(csvDir.filePath("separator-colon.csv")));
Chris@1524 90 QCOMPARE(f.getSeparator(), QChar(':'));
Chris@1524 91 QCOMPARE(f.getColumnCount(), 3);
Chris@1524 92 }
Chris@1524 93
Chris@1585 94 void plausibleSeparators() {
Chris@1585 95 CSVFormat f;
Chris@1585 96 QVERIFY(f.guessFormatFor(csvDir.filePath("separator-many.csv")));
Chris@1585 97 std::set<QChar> p;
Chris@1585 98 p.insert(QChar('|'));
Chris@1585 99 p.insert(QChar(','));
Chris@1585 100 p.insert(QChar(':'));
Chris@1585 101 p.insert(QChar(' '));
Chris@1585 102 std::set<QChar> actual = f.getPlausibleSeparators();
Chris@1585 103 QCOMPARE(actual, p);
Chris@1585 104 }
Chris@1585 105
Chris@1524 106 void comment() {
Chris@1524 107 CSVFormat f;
Chris@1870 108 f.setHeaderStatus(CSVFormat::HeaderAbsent);
Chris@1524 109 QVERIFY(f.guessFormatFor(csvDir.filePath("comment.csv")));
Chris@1524 110 QCOMPARE(f.getSeparator(), QChar(','));
Chris@1524 111 QCOMPARE(f.getColumnCount(), 4);
Chris@1345 112 }
Chris@1345 113
Chris@1524 114 void qualities() {
Chris@1524 115 CSVFormat f;
Chris@1524 116 QVERIFY(f.guessFormatFor(csvDir.filePath("column-qualities.csv")));
Chris@1524 117 QCOMPARE(f.getSeparator(), QChar(','));
Chris@1524 118 QCOMPARE(f.getColumnCount(), 7);
Chris@1524 119 QList<CSVFormat::ColumnQualities> q = f.getColumnQualities();
Chris@1524 120 QList<CSVFormat::ColumnQualities> expected;
Chris@1524 121 expected << 0;
Chris@1524 122 expected << CSVFormat::ColumnQualities(CSVFormat::ColumnNumeric |
Chris@1524 123 CSVFormat::ColumnIntegral |
Chris@1524 124 CSVFormat::ColumnIncreasing);
Chris@1524 125 expected << CSVFormat::ColumnQualities(CSVFormat::ColumnNumeric |
Chris@1524 126 CSVFormat::ColumnIntegral |
Chris@1524 127 CSVFormat::ColumnIncreasing |
Chris@1524 128 CSVFormat::ColumnLarge);
Chris@1524 129 expected << CSVFormat::ColumnQualities(CSVFormat::ColumnNumeric);
Chris@1524 130 expected << CSVFormat::ColumnQualities(CSVFormat::ColumnNumeric |
Chris@1524 131 CSVFormat::ColumnIncreasing);
Chris@1524 132 expected << CSVFormat::ColumnQualities(CSVFormat::ColumnNumeric |
Chris@1524 133 CSVFormat::ColumnSmall |
Chris@1524 134 CSVFormat::ColumnSigned);
Chris@1524 135 expected << CSVFormat::ColumnQualities(CSVFormat::ColumnNumeric |
Chris@1524 136 CSVFormat::ColumnIntegral |
Chris@1524 137 CSVFormat::ColumnIncreasing |
Chris@1524 138 CSVFormat::ColumnNearEmpty);
Chris@1524 139 QCOMPARE(q, expected);
Chris@1359 140 }
Chris@1525 141
Chris@1525 142 void modelType1DSamples() {
Chris@1525 143 CSVFormat f;
Chris@1525 144 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-samples.csv")));
Chris@1525 145 QCOMPARE(f.getColumnCount(), 1);
Chris@1870 146 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
Chris@1870 147 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1870 148 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1870 149 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
Chris@1870 150 QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel);
Chris@1870 151 }
Chris@1870 152
Chris@1870 153 void modelType1DSamplesWithHeader() {
Chris@1870 154 CSVFormat f;
Chris@1870 155 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-samples-header.csv")));
Chris@1870 156 QCOMPARE(f.getColumnCount(), 1);
Chris@1870 157 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
Chris@1525 158 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1525 159 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1525 160 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
Chris@1525 161 QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel);
Chris@1525 162 }
Chris@1525 163
Chris@1525 164 void modelType1DSeconds() {
Chris@1525 165 CSVFormat f;
Chris@1525 166 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-seconds.csv")));
Chris@1525 167 QCOMPARE(f.getColumnCount(), 2);
Chris@1870 168 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
Chris@1870 169 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1870 170 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnLabel);
Chris@1870 171 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1870 172 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
Chris@1870 173 QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel);
Chris@1870 174 }
Chris@1870 175
Chris@1870 176 void modelType1DSecondsWithHeader() {
Chris@1870 177 CSVFormat f;
Chris@1870 178 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-seconds-header.csv")));
Chris@1870 179 QCOMPARE(f.getColumnCount(), 2);
Chris@1870 180 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
Chris@1525 181 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1525 182 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnLabel);
Chris@1525 183 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1525 184 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
Chris@1525 185 QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel);
Chris@1525 186 }
Chris@1525 187
Chris@1525 188 void modelType2DSamples() {
Chris@1525 189 CSVFormat f;
Chris@1525 190 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-samples.csv")));
Chris@1525 191 QCOMPARE(f.getColumnCount(), 2);
Chris@1870 192 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
Chris@1870 193 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1870 194 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1870 195 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1870 196 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
Chris@1870 197 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel);
Chris@1870 198 }
Chris@1870 199
Chris@1870 200 void modelType2DSamplesWithHeader() {
Chris@1870 201 CSVFormat f;
Chris@1870 202 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-samples-header.csv")));
Chris@1870 203 QCOMPARE(f.getColumnCount(), 2);
Chris@1870 204 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
Chris@1525 205 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1525 206 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1525 207 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1525 208 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
Chris@1525 209 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel);
Chris@1525 210 }
Chris@1525 211
Chris@1525 212 void modelType2DSeconds() {
Chris@1525 213 CSVFormat f;
Chris@1525 214 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-seconds.csv")));
Chris@1525 215 QCOMPARE(f.getColumnCount(), 2);
Chris@1870 216 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
Chris@1870 217 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1870 218 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1870 219 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1870 220 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
Chris@1870 221 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel);
Chris@1870 222 }
Chris@1870 223
Chris@1870 224 void modelType2DSecondsWithHeader() {
Chris@1870 225 CSVFormat f;
Chris@1870 226 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-seconds-header.csv")));
Chris@1870 227 QCOMPARE(f.getColumnCount(), 2);
Chris@1870 228 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
Chris@1525 229 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1525 230 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1525 231 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1525 232 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
Chris@1525 233 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel);
Chris@1525 234 }
Chris@1525 235
Chris@1525 236 void modelType2DImplicit() {
Chris@1525 237 CSVFormat f;
Chris@1525 238 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-implicit.csv")));
Chris@1873 239 QCOMPARE(f.getColumnCount(), 2);
Chris@1870 240 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
Chris@1870 241 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue);
Chris@1873 242 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnLabel);
Chris@1870 243 QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming);
Chris@1870 244 }
Chris@1870 245
Chris@1870 246 void modelType2DImplicitWithHeader() {
Chris@1870 247 CSVFormat f;
Chris@1870 248 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-implicit-header.csv")));
Chris@1870 249 QCOMPARE(f.getColumnCount(), 2);
Chris@1870 250 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
Chris@1525 251 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue);
Chris@1873 252 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnLabel);
Chris@1525 253 QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming);
Chris@1525 254 }
Chris@1525 255
Chris@1525 256 void modelType2DEndTimeSamples() {
Chris@1525 257 CSVFormat f;
Chris@1525 258 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-samples.csv")));
Chris@1525 259 QCOMPARE(f.getColumnCount(), 3);
Chris@1870 260 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
Chris@1525 261 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1525 262 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnEndTime);
Chris@1525 263 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
Chris@1525 264 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1525 265 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
Chris@1525 266 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
Chris@1525 267 }
Chris@1525 268
Chris@1870 269 void modelType2DEndTimeSamplesWithHeader() {
Chris@1870 270 CSVFormat f;
Chris@1870 271 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-samples-header.csv")));
Chris@1870 272 QCOMPARE(f.getColumnCount(), 3);
Chris@1870 273 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
Chris@1870 274 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1870 275 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1870 276 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnEndTime);
Chris@1870 277 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1870 278 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
Chris@1870 279 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
Chris@1870 280 }
Chris@1870 281
Chris@1525 282 void modelType2DEndTimeSeconds() {
Chris@1525 283 CSVFormat f;
Chris@1525 284 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-seconds.csv")));
Chris@1525 285 QCOMPARE(f.getColumnCount(), 3);
Chris@1870 286 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
Chris@1525 287 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1525 288 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnEndTime);
Chris@1525 289 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
Chris@1525 290 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1525 291 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
Chris@1525 292 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
Chris@1525 293 }
Chris@1525 294
Chris@1870 295 void modelType2DEndTimeSecondsWithHeader() {
Chris@1870 296 CSVFormat f;
Chris@1870 297 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-seconds-header.csv")));
Chris@1870 298 QCOMPARE(f.getColumnCount(), 3);
Chris@1870 299 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
Chris@1870 300 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1870 301 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1870 302 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnEndTime);
Chris@1870 303 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1870 304 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
Chris@1870 305 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
Chris@1870 306 }
Chris@1870 307
Chris@1525 308 void modelType2DDurationSamples() {
Chris@1525 309 CSVFormat f;
Chris@1525 310 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-samples.csv")));
Chris@1525 311 QCOMPARE(f.getColumnCount(), 3);
Chris@1870 312 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
Chris@1525 313 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1525 314 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnDuration);
Chris@1525 315 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
Chris@1525 316 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1525 317 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
Chris@1525 318 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
Chris@1525 319 }
Chris@1870 320
Chris@1870 321 void modelType2DDurationSamplesWithHeader() {
Chris@1870 322 CSVFormat f;
Chris@1870 323 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-samples-header.csv")));
Chris@1870 324 QCOMPARE(f.getColumnCount(), 3);
Chris@1870 325 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
Chris@1870 326 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1870 327 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1870 328 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnDuration);
Chris@1870 329 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1870 330 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
Chris@1870 331 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
Chris@1870 332 }
Chris@1525 333
Chris@1525 334 void modelType2DDurationSeconds() {
Chris@1525 335 CSVFormat f;
Chris@1525 336 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-seconds.csv")));
Chris@1525 337 QCOMPARE(f.getColumnCount(), 3);
Chris@1870 338 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
Chris@1525 339 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1525 340 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnDuration);
Chris@1525 341 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
Chris@1525 342 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1525 343 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
Chris@1525 344 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
Chris@1525 345 }
Chris@1525 346
Chris@1870 347 void modelType2DDurationSecondsWithHeader() {
Chris@1870 348 CSVFormat f;
Chris@1870 349 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-seconds-header.csv")));
Chris@1870 350 QCOMPARE(f.getColumnCount(), 3);
Chris@1870 351 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
Chris@1870 352 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1870 353 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1870 354 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnDuration);
Chris@1870 355 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1870 356 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
Chris@1870 357 QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration);
Chris@1870 358 }
Chris@1870 359
Chris@1525 360 void modelType3DSamples() {
Chris@1525 361 CSVFormat f;
Chris@1525 362 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-samples.csv")));
Chris@1525 363 QCOMPARE(f.getColumnCount(), 7);
Chris@1870 364 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
Chris@1870 365 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1870 366 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1870 367 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
Chris@1870 368 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue);
Chris@1870 369 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue);
Chris@1870 370 QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue);
Chris@1870 371 QCOMPARE(f.getColumnPurpose(6), CSVFormat::ColumnValue);
Chris@1870 372 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1870 373 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
Chris@1870 374 QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel);
Chris@1870 375 }
Chris@1870 376
Chris@1870 377 void modelType3DSamplesWithHeader() {
Chris@1870 378 CSVFormat f;
Chris@1870 379 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-samples-header.csv")));
Chris@1870 380 QCOMPARE(f.getColumnCount(), 7);
Chris@1870 381 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
Chris@1525 382 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1525 383 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1525 384 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
Chris@1525 385 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue);
Chris@1525 386 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue);
Chris@1525 387 QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue);
Chris@1525 388 QCOMPARE(f.getColumnPurpose(6), CSVFormat::ColumnValue);
Chris@1525 389 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1525 390 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames);
Chris@1525 391 QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel);
Chris@1525 392 }
Chris@1525 393
Chris@1525 394 void modelType3DSeconds() {
Chris@1525 395 CSVFormat f;
Chris@1525 396 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-seconds.csv")));
Chris@1525 397 QCOMPARE(f.getColumnCount(), 7);
Chris@1870 398 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
Chris@1870 399 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1870 400 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1870 401 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
Chris@1870 402 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue);
Chris@1870 403 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue);
Chris@1870 404 QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue);
Chris@1870 405 QCOMPARE(f.getColumnPurpose(6), CSVFormat::ColumnValue);
Chris@1870 406 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1870 407 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
Chris@1870 408 QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel);
Chris@1870 409 }
Chris@1870 410
Chris@1870 411 void modelType3DSecondsWithHeader() {
Chris@1870 412 CSVFormat f;
Chris@1870 413 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-seconds-header.csv")));
Chris@1870 414 QCOMPARE(f.getColumnCount(), 7);
Chris@1870 415 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
Chris@1525 416 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime);
Chris@1525 417 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1525 418 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
Chris@1525 419 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue);
Chris@1525 420 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue);
Chris@1525 421 QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue);
Chris@1525 422 QCOMPARE(f.getColumnPurpose(6), CSVFormat::ColumnValue);
Chris@1525 423 QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming);
Chris@1525 424 QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds);
Chris@1525 425 QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel);
Chris@1525 426 }
Chris@1525 427
Chris@1525 428 void modelType3DImplicit() {
Chris@1525 429 CSVFormat f;
Chris@1525 430 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-implicit.csv")));
Chris@1525 431 QCOMPARE(f.getColumnCount(), 6);
Chris@1870 432 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent);
Chris@1870 433 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue);
Chris@1870 434 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1870 435 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
Chris@1870 436 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue);
Chris@1870 437 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue);
Chris@1870 438 QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue);
Chris@1870 439 QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming);
Chris@1870 440 QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel);
Chris@1870 441 }
Chris@1870 442
Chris@1870 443 void modelType3DImplicitWithHeader() {
Chris@1870 444 CSVFormat f;
Chris@1870 445 QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-implicit-header.csv")));
Chris@1870 446 QCOMPARE(f.getColumnCount(), 6);
Chris@1870 447 QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent);
Chris@1525 448 QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue);
Chris@1525 449 QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue);
Chris@1525 450 QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue);
Chris@1525 451 QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue);
Chris@1525 452 QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue);
Chris@1525 453 QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue);
Chris@1525 454 QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming);
Chris@1525 455 QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel);
Chris@1525 456 }
Chris@1525 457
Chris@1345 458 };
Chris@1345 459
Chris@1345 460 #endif