diff data/model/test/TestSparseModels.h @ 1644:513192aa9b03 single-point

Further API updates
author Chris Cannam
date Wed, 13 Mar 2019 16:00:13 +0000
parents 7a23dfe65d66
children 7a56bb85030f
line wrap: on
line diff
--- a/data/model/test/TestSparseModels.h	Wed Mar 13 14:50:10 2019 +0000
+++ b/data/model/test/TestSparseModels.h	Wed Mar 13 16:00:13 2019 +0000
@@ -138,28 +138,28 @@
     void note_extents() {
         NoteModel m(100, 10, false);
         Event p1(20, 123.4f, 40, 0.8f, "note 1");
-        m.addPoint(p1);
+        m.add(p1);
         QCOMPARE(m.isEmpty(), false);
-        QCOMPARE(m.getPointCount(), 1);
+        QCOMPARE(m.getEventCount(), 1);
         Event p2(50, 124.3f, 30, 0.9f, "note 2");
-        m.addPoint(p2);
+        m.add(p2);
         QCOMPARE(m.isEmpty(), false);
-        QCOMPARE(m.getPointCount(), 2);
-        QCOMPARE(m.getPoints().size(), 2);
-        QCOMPARE(*m.getPoints().begin(), p1);
-        QCOMPARE(*m.getPoints().rbegin(), p2);
+        QCOMPARE(m.getEventCount(), 2);
+        QCOMPARE(m.getAllEvents().size(), 2);
+        QCOMPARE(*m.getAllEvents().begin(), p1);
+        QCOMPARE(*m.getAllEvents().rbegin(), p2);
         QCOMPARE(m.getStartFrame(), 20);
         QCOMPARE(m.getEndFrame(), 80);
-        QCOMPARE(m.containsPoint(p1), true);
+        QCOMPARE(m.containsEvent(p1), true);
         QCOMPARE(m.getValueMinimum(), 123.4f);
         QCOMPARE(m.getValueMaximum(), 124.3f);
-        m.deletePoint(p1);
-        QCOMPARE(m.getPointCount(), 1);
-        QCOMPARE(m.getPoints().size(), 1);
-        QCOMPARE(*m.getPoints().begin(), p2);
+        m.remove(p1);
+        QCOMPARE(m.getEventCount(), 1);
+        QCOMPARE(m.getAllEvents().size(), 1);
+        QCOMPARE(*m.getAllEvents().begin(), p2);
         QCOMPARE(m.getStartFrame(), 50);
         QCOMPARE(m.getEndFrame(), 80);
-        QCOMPARE(m.containsPoint(p1), false);
+        QCOMPARE(m.containsEvent(p1), false);
     }
              
     void note_sample() {
@@ -167,30 +167,29 @@
         Event p1(20, 123.4f, 10, 0.8f, "note 1");
         Event p2(20, 124.3f, 20, 0.9f, "note 2");
         Event p3(50, 126.3f, 30, 0.9f, "note 3");
-        m.addPoint(p1);
-        m.addPoint(p2);
-        m.addPoint(p3);
+        m.add(p1);
+        m.add(p2);
+        m.add(p3);
 
-        QCOMPARE(m.getPoints().size(), 3);
-        QCOMPARE(*m.getPoints().begin(), p1);
-        QCOMPARE(*m.getPoints().rbegin(), p3);
+        QCOMPARE(m.getAllEvents().size(), 3);
+        QCOMPARE(*m.getAllEvents().begin(), p1);
+        QCOMPARE(*m.getAllEvents().rbegin(), p3);
 
-        auto pp = m.getPoints(20, 30);
+        auto pp = m.getEventsSpanning(20, 10);
         QCOMPARE(pp.size(), 2);
         QCOMPARE(*pp.begin(), p1);
         QCOMPARE(*pp.rbegin(), p2);
 
-        pp = m.getPoints(30, 50);
+        pp = m.getEventsSpanning(30, 20);
         QCOMPARE(pp.size(), 1);
         QCOMPARE(*pp.begin(), p2);
 
-        pp = m.getPoints(40, 50);
+        pp = m.getEventsSpanning(40, 10);
         QCOMPARE(pp.size(), 0);
 
-        //!!! this is a poor api
-        pp = m.getPoints(50, 50);
-        QCOMPARE(pp.size(), 0);
-//        QCOMPARE(*pp.begin(), p3);
+        pp = m.getEventsCovering(50);
+        QCOMPARE(pp.size(), 1);
+        QCOMPARE(*pp.begin(), p3);
     }
 
     void note_xml() {
@@ -199,9 +198,9 @@
         Event p2(20, 124.3f, 10, 0.9f, "note 2");
         Event p3(50, 126.3f, 30, 0.9f, "note 3");
         m.setScaleUnits("Hz");
-        m.addPoint(p1);
-        m.addPoint(p2);
-        m.addPoint(p3);
+        m.add(p1);
+        m.add(p2);
+        m.add(p3);
         QString xml;
         QTextStream str(&xml, QIODevice::WriteOnly);
         m.toXml(str);