comparison data/model/test/TestSparseModels.h @ 1662:628ffbb05856 single-point

Update PathModel - doesn't use new EventSeries, but doesn't use SparseModel either - it's simpler than that
author Chris Cannam
date Fri, 22 Mar 2019 13:32:09 +0000
parents 353a2d15f213
children a77a7e8c085c
comparison
equal deleted inserted replaced
1661:353a2d15f213 1662:628ffbb05856
16 #define TEST_SPARSE_MODELS_H 16 #define TEST_SPARSE_MODELS_H
17 17
18 #include "../SparseOneDimensionalModel.h" 18 #include "../SparseOneDimensionalModel.h"
19 #include "../NoteModel.h" 19 #include "../NoteModel.h"
20 #include "../TextModel.h" 20 #include "../TextModel.h"
21 #include "../PathModel.h"
21 22
22 #include <QObject> 23 #include <QObject>
23 #include <QtTest> 24 #include <QtTest>
24 25
25 #include <iostream> 26 #include <iostream>
244 cerr << "Obtained xml:\n" << xml 245 cerr << "Obtained xml:\n" << xml
245 << "\nExpected:\n" << expected << endl; 246 << "\nExpected:\n" << expected << endl;
246 } 247 }
247 QCOMPARE(xml, expected); 248 QCOMPARE(xml, expected);
248 } 249 }
250
251 void path_xml() {
252 PathModel m(100, 10, false);
253 PathPoint p1(20, 30);
254 PathPoint p2(40, 60);
255 PathPoint p3(50, 49);
256 m.addPoint(p1);
257 m.addPoint(p2);
258 m.addPoint(p3);
259 QString xml;
260 QTextStream str(&xml, QIODevice::WriteOnly);
261 m.toXml(str);
262 str.flush();
263
264 QString expected =
265 "<model id='7' name='' sampleRate='100' start='20' end='80' type='sparse' dimensions='2' resolution='10' notifyOnAdd='true' dataset='4' subtype='path' />\n"
266 "<dataset id='6' dimensions='2'>\n"
267 " <point frame='20' mapframe='30' />\n"
268 " <point frame='40' mapframe='60' />\n"
269 " <point frame='50' mapframe='49' />\n"
270 "</dataset>\n";
271 expected.replace("\'", "\"");
272 if (xml != expected) {
273 cerr << "Obtained xml:\n" << xml
274 << "\nExpected:\n" << expected << endl;
275 }
276 QCOMPARE(xml, expected);
277 }
249 278
250 }; 279 };
251 280
252 #endif 281 #endif