# HG changeset patch # User Chris Cannam # Date 1592484168 -3600 # Node ID 1d44fdc8196c354840432b495fd828e403a2bc97 # Parent 566476eeeb80b420cc9b88c722b1b0478106b830 Extend tests to include testing (at least some of) the actual data as well as the layout diff -r 566476eeeb80 -r 1d44fdc8196c data/fileio/test/CSVFormatTest.h --- a/data/fileio/test/CSVFormatTest.h Thu Jun 18 11:55:28 2020 +0100 +++ b/data/fileio/test/CSVFormatTest.h Thu Jun 18 13:42:48 2020 +0100 @@ -236,9 +236,10 @@ void modelType2DImplicit() { CSVFormat f; QVERIFY(f.guessFormatFor(csvDir.filePath("model-type-2d-implicit.csv"))); - QCOMPARE(f.getColumnCount(), 1); + QCOMPARE(f.getColumnCount(), 2); QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderAbsent); QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue); + QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnLabel); QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming); } @@ -248,6 +249,7 @@ QCOMPARE(f.getColumnCount(), 2); QCOMPARE(f.getHeaderStatus(), CSVFormat::HeaderPresent); QCOMPARE(f.getColumnPurpose(0), CSVFormat::ColumnValue); + QCOMPARE(f.getColumnPurpose(1), CSVFormat::ColumnLabel); QCOMPARE(f.getTimingType(), CSVFormat::ImplicitTiming); } diff -r 566476eeeb80 -r 1d44fdc8196c data/fileio/test/CSVReaderTest.h --- a/data/fileio/test/CSVReaderTest.h Thu Jun 18 11:55:28 2020 +0100 +++ b/data/fileio/test/CSVReaderTest.h Thu Jun 18 13:42:48 2020 +0100 @@ -77,7 +77,10 @@ auto actual = qobject_cast(model); QVERIFY(actual); QCOMPARE(actual->getAllEvents().size(), 5); - //!!! + the actual contents + vector expected { 45678, 123239, 320130, 452103, 620301 }; + for (int i = 0; in_range_for(expected, i); ++i) { + QCOMPARE(actual->getAllEvents()[i], Event(expected[i])); + } delete model; } @@ -87,7 +90,10 @@ auto actual = qobject_cast(model); QVERIFY(actual); QCOMPARE(actual->getAllEvents().size(), 5); - //!!! + the actual contents + vector expected { 45678, 123239, 320130, 452103, 620301 }; + for (int i = 0; in_range_for(expected, i); ++i) { + QCOMPARE(actual->getAllEvents()[i], Event(expected[i])); + } delete model; } @@ -197,6 +203,15 @@ auto actual = qobject_cast(model); QVERIFY(actual); QCOMPARE(actual->getAllEvents().size(), 5); + vector expectedFrames { 0, 1024, 2048, 3072, 4096 }; + vector expectedValues { 4.f, 4.2f, 0.4f, 3.8f, -2.3f }; + vector expectedLabels { {}, {}, "A label", {}, {} }; + for (int i = 0; in_range_for(expectedFrames, i); ++i) { + QCOMPARE(actual->getAllEvents()[i], + Event(expectedFrames[i], + expectedValues[i], + expectedLabels[i])); + } delete model; } @@ -206,6 +221,15 @@ auto actual = qobject_cast(model); QVERIFY(actual); QCOMPARE(actual->getAllEvents().size(), 5); + vector expectedFrames { 0, 1024, 2048, 3072, 4096 }; + vector expectedValues { 4.f, 4.2f, 0.4f, 3.8f, -2.3f }; + vector expectedLabels { {}, {}, "A label", {}, {} }; + for (int i = 0; in_range_for(expectedFrames, i); ++i) { + QCOMPARE(actual->getAllEvents()[i], + Event(expectedFrames[i], + expectedValues[i], + expectedLabels[i])); + } delete model; } diff -r 566476eeeb80 -r 1d44fdc8196c data/fileio/test/csv/model-type-1d-samples-header.csv --- a/data/fileio/test/csv/model-type-1d-samples-header.csv Thu Jun 18 11:55:28 2020 +0100 +++ b/data/fileio/test/csv/model-type-1d-samples-header.csv Thu Jun 18 13:42:48 2020 +0100 @@ -1,6 +1,6 @@ FRAME,LABEL 45678 123239 +452103 320130 -452103 620301 \ No newline at end of file diff -r 566476eeeb80 -r 1d44fdc8196c data/fileio/test/csv/model-type-2d-implicit.csv --- a/data/fileio/test/csv/model-type-2d-implicit.csv Thu Jun 18 11:55:28 2020 +0100 +++ b/data/fileio/test/csv/model-type-2d-implicit.csv Thu Jun 18 13:42:48 2020 +0100 @@ -1,5 +1,5 @@ 4 4.2 -0.4 +0.4,A label 3.8 -2.3