Mercurial > hg > svcore
diff data/model/test/TestSparseModels.h @ 1661:353a2d15f213 single-point
Update TextModel
author | Chris Cannam |
---|---|
date | Fri, 22 Mar 2019 11:04:51 +0000 |
parents | 8bf3a52a1604 |
children | 628ffbb05856 |
line wrap: on
line diff
--- a/data/model/test/TestSparseModels.h Thu Mar 21 13:33:30 2019 +0000 +++ b/data/model/test/TestSparseModels.h Fri Mar 22 11:04:51 2019 +0000 @@ -17,6 +17,7 @@ #include "../SparseOneDimensionalModel.h" #include "../NoteModel.h" +#include "../TextModel.h" #include <QObject> #include <QtTest> @@ -217,6 +218,34 @@ } QCOMPARE(xml, expected); } + + void text_xml() { + TextModel m(100, 10, false); + Event p1(20, 1.0f, "text 1"); + Event p2(20, 0.0f, "text 2"); + Event p3(50, 0.3f, "text 3"); + m.add(p1); + m.add(p2); + m.add(p3); + QString xml; + QTextStream str(&xml, QIODevice::WriteOnly); + m.toXml(str); + str.flush(); + + QString expected = + "<model id='5' name='' sampleRate='100' start='20' end='80' type='sparse' dimensions='2' resolution='10' notifyOnAdd='true' dataset='4' subtype='text' />\n" + "<dataset id='4' dimensions='2'>\n" + " <point frame='20' height='0' label='text 2' />\n" + " <point frame='20' height='1' label='text 1' />\n" + " <point frame='50' height='0.3' label='text 3' />\n" + "</dataset>\n"; + expected.replace("\'", "\""); + if (xml != expected) { + cerr << "Obtained xml:\n" << xml + << "\nExpected:\n" << expected << endl; + } + QCOMPARE(xml, expected); + } };