changeset 1609:560453546749 single-point

Start some sparse model tests
author Chris Cannam
date Tue, 05 Mar 2019 13:21:55 +0000
parents 0e0947896fd3
children 7db29268cf4c
files data/fileio/CSVStreamWriter.h data/fileio/test/CSVStreamWriterTest.h data/model/SparseModel.h data/model/SparseOneDimensionalModel.h data/model/test/files.pri data/model/test/svcore-data-model-test.cpp
diffstat 6 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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() );
     }
--- 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;
--- 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);
+    }
 };
 
 
--- 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
 	
--- 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;