Chris@1345: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@1345: Chris@1345: /* Chris@1345: Sonic Visualiser Chris@1345: An audio file viewer and annotation editor. Chris@1345: Centre for Digital Music, Queen Mary, University of London. Chris@1345: Chris@1345: This program is free software; you can redistribute it and/or Chris@1345: modify it under the terms of the GNU General Public License as Chris@1345: published by the Free Software Foundation; either version 2 of the Chris@1345: License, or (at your option) any later version. See the file Chris@1345: COPYING included with this distribution for more information. Chris@1345: */ Chris@1345: Chris@1524: #ifndef TEST_CSV_FORMAT_H Chris@1524: #define TEST_CSV_FORMAT_H Chris@1345: Chris@1524: // Tests for the code that guesses the most likely format for parsing a CSV file Chris@1345: Chris@1524: #include "../CSVFormat.h" Chris@1524: Chris@1524: #include "base/Debug.h" Chris@1345: Chris@1345: #include Chris@1345: Chris@1345: #include Chris@1345: #include Chris@1345: #include Chris@1345: Chris@1345: #include Chris@1345: Chris@1345: using namespace std; Chris@1345: Chris@1524: class CSVFormatTest : public QObject Chris@1345: { Chris@1345: Q_OBJECT Chris@1345: Chris@1346: private: Chris@1524: QDir csvDir; Chris@1346: Chris@1346: public: Chris@1524: CSVFormatTest(QString base) { Chris@1346: if (base == "") { Chris@1346: base = "svcore/data/fileio/test"; Chris@1346: } Chris@1524: csvDir = QDir(base + "/csv"); Chris@1346: } Chris@1346: Chris@1524: private slots: Chris@1524: void init() { Chris@1524: if (!csvDir.exists()) { Chris@1524: SVCERR << "ERROR: CSV test file directory \"" << csvDir.absolutePath() << "\" does not exist" << endl; Chris@1524: QVERIFY2(csvDir.exists(), "CSV test file directory not found"); Chris@1359: } Chris@1359: } Chris@1359: Chris@1524: void separatorComma() { Chris@1524: CSVFormat f; Chris@1524: QVERIFY(f.guessFormatFor(csvDir.filePath("separator-comma.csv"))); Chris@1524: QCOMPARE(f.getSeparator(), QChar(',')); Chris@1524: QCOMPARE(f.getColumnCount(), 3); Chris@1524: } Chris@1524: Chris@1524: void separatorTab() { Chris@1524: CSVFormat f; Chris@1524: QVERIFY(f.guessFormatFor(csvDir.filePath("separator-tab.csv"))); Chris@1524: QCOMPARE(f.getSeparator(), QChar('\t')); Chris@1524: QCOMPARE(f.getColumnCount(), 3); Chris@1524: } Chris@1524: Chris@1524: void separatorPipe() { Chris@1524: CSVFormat f; Chris@1524: QVERIFY(f.guessFormatFor(csvDir.filePath("separator-pipe.csv"))); Chris@1524: QCOMPARE(f.getSeparator(), QChar('|')); Chris@1524: // differs from the others Chris@1524: QCOMPARE(f.getColumnCount(), 4); Chris@1524: } Chris@1524: Chris@1524: void separatorSpace() { Chris@1524: CSVFormat f; Chris@1524: QVERIFY(f.guessFormatFor(csvDir.filePath("separator-space.csv"))); Chris@1524: QCOMPARE(f.getSeparator(), QChar(' ')); Chris@1524: // NB fields are separated by 1 or more spaces, not necessarily exactly 1 Chris@1524: QCOMPARE(f.getColumnCount(), 3); Chris@1524: } Chris@1524: Chris@1524: void separatorColon() { Chris@1524: CSVFormat f; Chris@1524: QVERIFY(f.guessFormatFor(csvDir.filePath("separator-colon.csv"))); Chris@1524: QCOMPARE(f.getSeparator(), QChar(':')); Chris@1524: QCOMPARE(f.getColumnCount(), 3); Chris@1524: } Chris@1524: Chris@1585: void plausibleSeparators() { Chris@1585: CSVFormat f; Chris@1585: QVERIFY(f.guessFormatFor(csvDir.filePath("separator-many.csv"))); Chris@1585: std::set p; Chris@1585: p.insert(QChar('|')); Chris@1585: p.insert(QChar(',')); Chris@1585: p.insert(QChar(':')); Chris@1585: p.insert(QChar(' ')); Chris@1585: std::set actual = f.getPlausibleSeparators(); Chris@1585: QCOMPARE(actual, p); Chris@1585: } Chris@1585: Chris@1524: void comment() { Chris@1524: CSVFormat f; Chris@1870: f.setHeaderStatus(CSVFormat::HeaderAbsent); Chris@1524: QVERIFY(f.guessFormatFor(csvDir.filePath("comment.csv"))); Chris@1524: QCOMPARE(f.getSeparator(), QChar(',')); Chris@1524: QCOMPARE(f.getColumnCount(), 4); Chris@1345: } Chris@1345: Chris@1524: void qualities() { Chris@1524: CSVFormat f; Chris@1524: QVERIFY(f.guessFormatFor(csvDir.filePath("column-qualities.csv"))); Chris@1524: QCOMPARE(f.getSeparator(), QChar(',')); Chris@1524: QCOMPARE(f.getColumnCount(), 7); Chris@1524: QList q = f.getColumnQualities(); Chris@1524: QList expected; Chris@1524: expected << 0; Chris@1524: expected << CSVFormat::ColumnQualities(CSVFormat::ColumnNumeric | Chris@1524: CSVFormat::ColumnIntegral | Chris@1524: CSVFormat::ColumnIncreasing); Chris@1524: expected << CSVFormat::ColumnQualities(CSVFormat::ColumnNumeric | Chris@1524: CSVFormat::ColumnIntegral | Chris@1524: CSVFormat::ColumnIncreasing | Chris@1524: CSVFormat::ColumnLarge); Chris@1524: expected << CSVFormat::ColumnQualities(CSVFormat::ColumnNumeric); Chris@1524: expected << CSVFormat::ColumnQualities(CSVFormat::ColumnNumeric | Chris@1524: CSVFormat::ColumnIncreasing); Chris@1524: expected << CSVFormat::ColumnQualities(CSVFormat::ColumnNumeric | Chris@1524: CSVFormat::ColumnSmall | Chris@1524: CSVFormat::ColumnSigned); Chris@1524: expected << CSVFormat::ColumnQualities(CSVFormat::ColumnNumeric | Chris@1524: CSVFormat::ColumnIntegral | Chris@1524: CSVFormat::ColumnIncreasing | Chris@1524: CSVFormat::ColumnNearEmpty); Chris@1524: QCOMPARE(q, expected); Chris@1359: } Chris@1525: Chris@1525: void modelType1DSamples() { Chris@1525: CSVFormat f; Chris@1525: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-samples.csv"))); Chris@1525: QCOMPARE(f.getColumnCount(), 1); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); Chris@1870: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1870: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1870: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); Chris@1870: QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel); Chris@1870: } Chris@1870: Chris@1870: void modelType1DSamplesWithHeader() { Chris@1870: CSVFormat f; Chris@1870: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-samples-header.csv"))); Chris@1870: QCOMPARE(f.getColumnCount(), 1); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); Chris@1525: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1525: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1525: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); Chris@1525: QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel); Chris@1525: } Chris@1525: Chris@1525: void modelType1DSeconds() { Chris@1525: CSVFormat f; Chris@1525: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-seconds.csv"))); Chris@1525: QCOMPARE(f.getColumnCount(), 2); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); Chris@1870: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1870: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnLabel); Chris@1870: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1870: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); Chris@1870: QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel); Chris@1870: } Chris@1870: Chris@1870: void modelType1DSecondsWithHeader() { Chris@1870: CSVFormat f; Chris@1870: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-1d-seconds-header.csv"))); Chris@1870: QCOMPARE(f.getColumnCount(), 2); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); Chris@1525: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1525: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnLabel); Chris@1525: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1525: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); Chris@1525: QCOMPARE(f.getModelType(), CSVFormat::OneDimensionalModel); Chris@1525: } Chris@1525: Chris@1525: void modelType2DSamples() { Chris@1525: CSVFormat f; Chris@1525: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-samples.csv"))); Chris@1525: QCOMPARE(f.getColumnCount(), 2); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); Chris@1870: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1870: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1870: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); Chris@1870: QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel); Chris@1870: } Chris@1870: Chris@1870: void modelType2DSamplesWithHeader() { Chris@1870: CSVFormat f; Chris@1870: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-samples-header.csv"))); Chris@1870: QCOMPARE(f.getColumnCount(), 2); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); Chris@1525: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1525: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1525: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); Chris@1525: QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel); Chris@1525: } Chris@1525: Chris@1525: void modelType2DSeconds() { Chris@1525: CSVFormat f; Chris@1525: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-seconds.csv"))); Chris@1525: QCOMPARE(f.getColumnCount(), 2); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); Chris@1870: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1870: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1870: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); Chris@1870: QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel); Chris@1870: } Chris@1870: Chris@1870: void modelType2DSecondsWithHeader() { Chris@1870: CSVFormat f; Chris@1870: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-seconds-header.csv"))); Chris@1870: QCOMPARE(f.getColumnCount(), 2); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); Chris@1525: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1525: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1525: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); Chris@1525: QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModel); Chris@1525: } Chris@1525: Chris@1525: void modelType2DImplicit() { Chris@1525: CSVFormat f; Chris@1525: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-implicit.csv"))); Chris@1525: QCOMPARE(f.getColumnCount(), 1); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); Chris@1870: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming); Chris@1870: } Chris@1870: Chris@1870: void modelType2DImplicitWithHeader() { Chris@1870: CSVFormat f; Chris@1870: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-implicit-header.csv"))); Chris@1870: QCOMPARE(f.getColumnCount(), 2); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); Chris@1525: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming); Chris@1525: } Chris@1525: Chris@1525: void modelType2DEndTimeSamples() { Chris@1525: CSVFormat f; Chris@1525: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-samples.csv"))); Chris@1525: QCOMPARE(f.getColumnCount(), 3); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); Chris@1525: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1525: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnEndTime); Chris@1525: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1525: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); Chris@1525: QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration); Chris@1525: } Chris@1525: Chris@1870: void modelType2DEndTimeSamplesWithHeader() { Chris@1870: CSVFormat f; Chris@1870: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-samples-header.csv"))); Chris@1870: QCOMPARE(f.getColumnCount(), 3); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); Chris@1870: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1870: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnEndTime); Chris@1870: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1870: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); Chris@1870: QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration); Chris@1870: } Chris@1870: Chris@1525: void modelType2DEndTimeSeconds() { Chris@1525: CSVFormat f; Chris@1525: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-seconds.csv"))); Chris@1525: QCOMPARE(f.getColumnCount(), 3); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); Chris@1525: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1525: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnEndTime); Chris@1525: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1525: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); Chris@1525: QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration); Chris@1525: } Chris@1525: Chris@1870: void modelType2DEndTimeSecondsWithHeader() { Chris@1870: CSVFormat f; Chris@1870: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-endtime-seconds-header.csv"))); Chris@1870: QCOMPARE(f.getColumnCount(), 3); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); Chris@1870: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1870: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnEndTime); Chris@1870: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1870: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); Chris@1870: QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration); Chris@1870: } Chris@1870: Chris@1525: void modelType2DDurationSamples() { Chris@1525: CSVFormat f; Chris@1525: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-samples.csv"))); Chris@1525: QCOMPARE(f.getColumnCount(), 3); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); Chris@1525: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1525: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnDuration); Chris@1525: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1525: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); Chris@1525: QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration); Chris@1525: } Chris@1870: Chris@1870: void modelType2DDurationSamplesWithHeader() { Chris@1870: CSVFormat f; Chris@1870: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-samples-header.csv"))); Chris@1870: QCOMPARE(f.getColumnCount(), 3); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); Chris@1870: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1870: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnDuration); Chris@1870: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1870: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); Chris@1870: QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration); Chris@1870: } Chris@1525: Chris@1525: void modelType2DDurationSeconds() { Chris@1525: CSVFormat f; Chris@1525: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-seconds.csv"))); Chris@1525: QCOMPARE(f.getColumnCount(), 3); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); Chris@1525: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1525: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnDuration); Chris@1525: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1525: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); Chris@1525: QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration); Chris@1525: } Chris@1525: Chris@1870: void modelType2DDurationSecondsWithHeader() { Chris@1870: CSVFormat f; Chris@1870: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-duration-seconds-header.csv"))); Chris@1870: QCOMPARE(f.getColumnCount(), 3); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); Chris@1870: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1870: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnDuration); Chris@1870: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1870: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); Chris@1870: QCOMPARE(f.getModelType(), CSVFormat::TwoDimensionalModelWithDuration); Chris@1870: } Chris@1870: Chris@1525: void modelType3DSamples() { Chris@1525: CSVFormat f; Chris@1525: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-samples.csv"))); Chris@1525: QCOMPARE(f.getColumnCount(), 7); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); Chris@1870: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1870: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(6), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1870: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); Chris@1870: QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel); Chris@1870: } Chris@1870: Chris@1870: void modelType3DSamplesWithHeader() { Chris@1870: CSVFormat f; Chris@1870: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-samples-header.csv"))); Chris@1870: QCOMPARE(f.getColumnCount(), 7); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); Chris@1525: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1525: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(6), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1525: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeAudioFrames); Chris@1525: QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel); Chris@1525: } Chris@1525: Chris@1525: void modelType3DSeconds() { Chris@1525: CSVFormat f; Chris@1525: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-seconds.csv"))); Chris@1525: QCOMPARE(f.getColumnCount(), 7); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); Chris@1870: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1870: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(6), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1870: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); Chris@1870: QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel); Chris@1870: } Chris@1870: Chris@1870: void modelType3DSecondsWithHeader() { Chris@1870: CSVFormat f; Chris@1870: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-seconds-header.csv"))); Chris@1870: QCOMPARE(f.getColumnCount(), 7); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); Chris@1525: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnStartTime); Chris@1525: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(6), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getTimingType(), CSVFormat::ExplicitTiming); Chris@1525: QCOMPARE(f.getTimeUnits(), CSVFormat::TimeSeconds); Chris@1525: QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel); Chris@1525: } Chris@1525: Chris@1525: void modelType3DImplicit() { Chris@1525: CSVFormat f; Chris@1525: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-implicit.csv"))); Chris@1525: QCOMPARE(f.getColumnCount(), 6); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); Chris@1870: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue); Chris@1870: QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming); Chris@1870: QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel); Chris@1870: } Chris@1870: Chris@1870: void modelType3DImplicitWithHeader() { Chris@1870: CSVFormat f; Chris@1870: QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-3d-implicit-header.csv"))); Chris@1870: QCOMPARE(f.getColumnCount(), 6); Chris@1870: QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); Chris@1525: QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(2), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(3), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(4), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getColumnPurpose(5), CSVFormat::ColumnValue); Chris@1525: QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming); Chris@1525: QCOMPARE(f.getModelType(), CSVFormat::ThreeDimensionalModel); Chris@1525: } Chris@1525: Chris@1345: }; Chris@1345: Chris@1345: #endif