Mercurial > hg > svcore
diff data/model/test/TestSparseModels.h @ 1677:f97d64b8674f single-point
Make XmlExportables store their export IDs and always obtain a new one, avoiding reuse when an object is allocated at the same heap location as a previous one. This makes the ID system stable enough to be used in the export tests.
author | Chris Cannam |
---|---|
date | Thu, 28 Mar 2019 11:55:02 +0000 |
parents | 69ab62d378bf |
children | 0d89abd631ac |
line wrap: on
line diff
--- a/data/model/test/TestSparseModels.h Thu Mar 28 10:39:24 2019 +0000 +++ b/data/model/test/TestSparseModels.h Thu Mar 28 11:55:02 2019 +0000 @@ -28,6 +28,11 @@ using namespace std; +// NB model & dataset IDs in the export tests are incremental, +// depending on how many have been exported in previous tests - so +// when adding or removing tests we may occasionally need to update +// the IDs in other ones + class TestSparseModels : public QObject { Q_OBJECT @@ -118,8 +123,8 @@ m.toXml(str); str.flush(); QString expected = - "<model id='1' name='This "&" that' sampleRate='100' start='20' end='60' type='sparse' dimensions='1' resolution='10' notifyOnAdd='true' dataset='0' />\n" - "<dataset id='0' dimensions='1'>\n" + "<model id='2' name='This "&" that' sampleRate='100' start='20' end='60' type='sparse' dimensions='1' resolution='10' notifyOnAdd='true' dataset='1' />\n" + "<dataset id='1' dimensions='1'>\n" " <point frame='20' />\n" " <point frame='20' label='Label &'">' />\n" " <point frame='50' />\n" @@ -202,14 +207,10 @@ QTextStream str(&xml, QIODevice::WriteOnly); m.toXml(str); str.flush(); - - //!!! This is not guaranteed - object export ids are in order - //!!! of model pointer value, which is not trustworthy - - //!!! replace them with something else QString expected = - "<model id='3' name='' sampleRate='100' start='20' end='80' type='sparse' dimensions='3' resolution='10' notifyOnAdd='true' dataset='2' subtype='note' valueQuantization='0' minimum='123.4' maximum='126.3' units='Hz' />\n" - "<dataset id='2' dimensions='3'>\n" + "<model id='4' name='' sampleRate='100' start='20' end='80' type='sparse' dimensions='3' resolution='10' notifyOnAdd='true' dataset='3' subtype='note' valueQuantization='0' minimum='123.4' maximum='126.3' units='Hz' />\n" + "<dataset id='3' dimensions='3'>\n" " <point frame='20' value='124.3' duration='10' level='0.9' label='note 2' />\n" " <point frame='20' value='123.4' duration='20' level='0.8' label='note 1' />\n" " <point frame='50' value='126.3' duration='30' level='0.9' label='note 3' />\n" @@ -236,8 +237,8 @@ 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" + "<model id='6' name='' sampleRate='100' start='20' end='60' type='sparse' dimensions='2' resolution='10' notifyOnAdd='true' dataset='5' subtype='text' />\n" + "<dataset id='5' 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" @@ -264,8 +265,8 @@ str.flush(); QString expected = - "<model id='7' name='' sampleRate='100' start='20' end='80' type='sparse' dimensions='2' resolution='10' notifyOnAdd='true' dataset='4' subtype='path' />\n" - "<dataset id='6' dimensions='2'>\n" + "<model id='7' name='' sampleRate='100' start='20' end='60' type='sparse' dimensions='2' resolution='10' notifyOnAdd='true' dataset='7' subtype='path' />\n" + "<dataset id='7' dimensions='2'>\n" " <point frame='20' mapframe='30' />\n" " <point frame='40' mapframe='60' />\n" " <point frame='50' mapframe='49' />\n" @@ -288,8 +289,8 @@ str.flush(); QString expected = - "<model id='4' name='' sampleRate='100' start='20' end='30' type='sparse' dimensions='1' resolution='10' notifyOnAdd='true' dataset='2' subtype='image' />\n" - "<dataset id='2' dimensions='1'>\n" + "<model id='9' name='' sampleRate='100' start='20' end='30' type='sparse' dimensions='1' resolution='10' notifyOnAdd='true' dataset='8' subtype='image' />\n" + "<dataset id='8' dimensions='1'>\n" " <point frame='20' label='a label' image='/path/to/thing.png' />\n" "</dataset>\n"; expected.replace("\'", "\"");