# HG changeset patch # User Chris Cannam # Date 1551792115 0 # Node ID 56045354674996a5dbe648088f0ccaaf9fa21591 # Parent 0e0947896fd3b2406983aca444ba98285c09528c Start some sparse model tests diff -r 0e0947896fd3 -r 560453546749 data/fileio/CSVStreamWriter.h --- a/data/fileio/CSVStreamWriter.h Wed Feb 27 12:31:12 2019 +0000 +++ b/data/fileio/CSVStreamWriter.h Tue Mar 05 13:21:55 2019 +0000 @@ -58,6 +58,7 @@ sv_frame_t nFramesWritten = 0; int previousProgress = 0; + bool started = false; for (const auto& extents : selections) { const auto startFrame = extents.getStartFrame(); @@ -76,7 +77,12 @@ ).trimmed(); if ( data != "" ) { - oss << data << (end < finalFrameOfLastRegion ? "\n" : ""); + if (started) { + oss << "\n"; + } else { + started = true; + } + oss << data; } nFramesWritten += end - start; diff -r 0e0947896fd3 -r 560453546749 data/fileio/test/CSVStreamWriterTest.h --- a/data/fileio/test/CSVStreamWriterTest.h Wed Feb 27 12:31:12 2019 +0000 +++ b/data/fileio/test/CSVStreamWriterTest.h Tue Mar 05 13:21:55 2019 +0000 @@ -318,8 +318,8 @@ 2 ); -// qDebug("\n%s\n", expectedOutput.toLocal8Bit().data()); -// qDebug("\n%s\n", oss.str().c_str()); +// qDebug("\n->>%s<<-\n", expectedOutput.toLocal8Bit().data()); +// qDebug("\n->>%s<<-\n", oss.str().c_str()); QVERIFY( wroteSparseModel == true ); QVERIFY( oss.str() == expectedOutput.toStdString() ); } diff -r 0e0947896fd3 -r 560453546749 data/model/SparseModel.h --- a/data/model/SparseModel.h Wed Feb 27 12:31:12 2019 +0000 +++ b/data/model/SparseModel.h Tue Mar 05 13:21:55 2019 +0000 @@ -580,7 +580,7 @@ sv_frame_t f = 0; if (!m_points.empty()) { PointListConstIterator i(m_points.end()); - f = (--i)->frame + 1; + f = (--i)->frame + getResolution(); } if (m_extendTo > f) { return m_extendTo; diff -r 0e0947896fd3 -r 560453546749 data/model/SparseOneDimensionalModel.h --- a/data/model/SparseOneDimensionalModel.h Wed Feb 27 12:31:12 2019 +0000 +++ b/data/model/SparseOneDimensionalModel.h Tue Mar 05 13:21:55 2019 +0000 @@ -67,6 +67,10 @@ return p1.frame < p2.frame; } }; + + bool operator==(const OneDimensionalPoint &p) const { + return (frame == p.frame && label == p.label); + } }; diff -r 0e0947896fd3 -r 560453546749 data/model/test/files.pri --- a/data/model/test/files.pri Wed Feb 27 12:31:12 2019 +0000 +++ b/data/model/test/files.pri Tue Mar 05 13:21:55 2019 +0000 @@ -2,6 +2,7 @@ Compares.h \ MockWaveModel.h \ TestFFTModel.h \ + TestSparseModels.h \ TestWaveformOversampler.h \ TestZoomConstraints.h diff -r 0e0947896fd3 -r 560453546749 data/model/test/svcore-data-model-test.cpp --- a/data/model/test/svcore-data-model-test.cpp Wed Feb 27 12:31:12 2019 +0000 +++ b/data/model/test/svcore-data-model-test.cpp Tue Mar 05 13:21:55 2019 +0000 @@ -14,6 +14,7 @@ #include "TestFFTModel.h" #include "TestZoomConstraints.h" #include "TestWaveformOversampler.h" +#include "TestSparseModels.h" #include "system/Init.h" @@ -31,7 +32,7 @@ QCoreApplication app(argc, argv); app.setOrganizationName("sonic-visualiser"); - app.setApplicationName("test-model"); + app.setApplicationName("test-svcore-data-model"); { TestFFTModel t; @@ -51,6 +52,12 @@ else ++bad; } + { + TestSparseModels t; + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; + } + if (bad > 0) { SVCERR << "\n********* " << bad << " test suite(s) failed!\n" << endl; return 1;