diff data/fileio/test/CSVReaderTest.h @ 1873:1d44fdc8196c csv-import-headers

Extend tests to include testing (at least some of) the actual data as well as the layout
author Chris Cannam
date Thu, 18 Jun 2020 13:42:48 +0100
parents 566476eeeb80
children f49afb5b9eac
line wrap: on
line diff
--- 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<SparseOneDimensionalModel *>(model);
         QVERIFY(actual);
         QCOMPARE(actual->getAllEvents().size(), 5);
-        //!!! + the actual contents
+        vector<sv_frame_t> 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<SparseOneDimensionalModel *>(model);
         QVERIFY(actual);
         QCOMPARE(actual->getAllEvents().size(), 5);
-        //!!! + the actual contents
+        vector<sv_frame_t> 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<SparseTimeValueModel *>(model);
         QVERIFY(actual);
         QCOMPARE(actual->getAllEvents().size(), 5);
+        vector<sv_frame_t> expectedFrames { 0, 1024, 2048, 3072, 4096 };
+        vector<float> expectedValues { 4.f, 4.2f, 0.4f, 3.8f, -2.3f };
+        vector<QString> 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<SparseTimeValueModel *>(model);
         QVERIFY(actual);
         QCOMPARE(actual->getAllEvents().size(), 5);
+        vector<sv_frame_t> expectedFrames { 0, 1024, 2048, 3072, 4096 };
+        vector<float> expectedValues { 4.f, 4.2f, 0.4f, 3.8f, -2.3f };
+        vector<QString> 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;
     }