comparison 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
comparison
equal deleted inserted replaced
1643:7a23dfe65d66 1644:513192aa9b03
136 } 136 }
137 137
138 void note_extents() { 138 void note_extents() {
139 NoteModel m(100, 10, false); 139 NoteModel m(100, 10, false);
140 Event p1(20, 123.4f, 40, 0.8f, "note 1"); 140 Event p1(20, 123.4f, 40, 0.8f, "note 1");
141 m.addPoint(p1); 141 m.add(p1);
142 QCOMPARE(m.isEmpty(), false); 142 QCOMPARE(m.isEmpty(), false);
143 QCOMPARE(m.getPointCount(), 1); 143 QCOMPARE(m.getEventCount(), 1);
144 Event p2(50, 124.3f, 30, 0.9f, "note 2"); 144 Event p2(50, 124.3f, 30, 0.9f, "note 2");
145 m.addPoint(p2); 145 m.add(p2);
146 QCOMPARE(m.isEmpty(), false); 146 QCOMPARE(m.isEmpty(), false);
147 QCOMPARE(m.getPointCount(), 2); 147 QCOMPARE(m.getEventCount(), 2);
148 QCOMPARE(m.getPoints().size(), 2); 148 QCOMPARE(m.getAllEvents().size(), 2);
149 QCOMPARE(*m.getPoints().begin(), p1); 149 QCOMPARE(*m.getAllEvents().begin(), p1);
150 QCOMPARE(*m.getPoints().rbegin(), p2); 150 QCOMPARE(*m.getAllEvents().rbegin(), p2);
151 QCOMPARE(m.getStartFrame(), 20); 151 QCOMPARE(m.getStartFrame(), 20);
152 QCOMPARE(m.getEndFrame(), 80); 152 QCOMPARE(m.getEndFrame(), 80);
153 QCOMPARE(m.containsPoint(p1), true); 153 QCOMPARE(m.containsEvent(p1), true);
154 QCOMPARE(m.getValueMinimum(), 123.4f); 154 QCOMPARE(m.getValueMinimum(), 123.4f);
155 QCOMPARE(m.getValueMaximum(), 124.3f); 155 QCOMPARE(m.getValueMaximum(), 124.3f);
156 m.deletePoint(p1); 156 m.remove(p1);
157 QCOMPARE(m.getPointCount(), 1); 157 QCOMPARE(m.getEventCount(), 1);
158 QCOMPARE(m.getPoints().size(), 1); 158 QCOMPARE(m.getAllEvents().size(), 1);
159 QCOMPARE(*m.getPoints().begin(), p2); 159 QCOMPARE(*m.getAllEvents().begin(), p2);
160 QCOMPARE(m.getStartFrame(), 50); 160 QCOMPARE(m.getStartFrame(), 50);
161 QCOMPARE(m.getEndFrame(), 80); 161 QCOMPARE(m.getEndFrame(), 80);
162 QCOMPARE(m.containsPoint(p1), false); 162 QCOMPARE(m.containsEvent(p1), false);
163 } 163 }
164 164
165 void note_sample() { 165 void note_sample() {
166 NoteModel m(100, 10, false); 166 NoteModel m(100, 10, false);
167 Event p1(20, 123.4f, 10, 0.8f, "note 1"); 167 Event p1(20, 123.4f, 10, 0.8f, "note 1");
168 Event p2(20, 124.3f, 20, 0.9f, "note 2"); 168 Event p2(20, 124.3f, 20, 0.9f, "note 2");
169 Event p3(50, 126.3f, 30, 0.9f, "note 3"); 169 Event p3(50, 126.3f, 30, 0.9f, "note 3");
170 m.addPoint(p1); 170 m.add(p1);
171 m.addPoint(p2); 171 m.add(p2);
172 m.addPoint(p3); 172 m.add(p3);
173 173
174 QCOMPARE(m.getPoints().size(), 3); 174 QCOMPARE(m.getAllEvents().size(), 3);
175 QCOMPARE(*m.getPoints().begin(), p1); 175 QCOMPARE(*m.getAllEvents().begin(), p1);
176 QCOMPARE(*m.getPoints().rbegin(), p3); 176 QCOMPARE(*m.getAllEvents().rbegin(), p3);
177 177
178 auto pp = m.getPoints(20, 30); 178 auto pp = m.getEventsSpanning(20, 10);
179 QCOMPARE(pp.size(), 2); 179 QCOMPARE(pp.size(), 2);
180 QCOMPARE(*pp.begin(), p1); 180 QCOMPARE(*pp.begin(), p1);
181 QCOMPARE(*pp.rbegin(), p2); 181 QCOMPARE(*pp.rbegin(), p2);
182 182
183 pp = m.getPoints(30, 50); 183 pp = m.getEventsSpanning(30, 20);
184 QCOMPARE(pp.size(), 1); 184 QCOMPARE(pp.size(), 1);
185 QCOMPARE(*pp.begin(), p2); 185 QCOMPARE(*pp.begin(), p2);
186 186
187 pp = m.getPoints(40, 50); 187 pp = m.getEventsSpanning(40, 10);
188 QCOMPARE(pp.size(), 0); 188 QCOMPARE(pp.size(), 0);
189 189
190 //!!! this is a poor api 190 pp = m.getEventsCovering(50);
191 pp = m.getPoints(50, 50); 191 QCOMPARE(pp.size(), 1);
192 QCOMPARE(pp.size(), 0); 192 QCOMPARE(*pp.begin(), p3);
193 // QCOMPARE(*pp.begin(), p3);
194 } 193 }
195 194
196 void note_xml() { 195 void note_xml() {
197 NoteModel m(100, 10, false); 196 NoteModel m(100, 10, false);
198 Event p1(20, 123.4f, 20, 0.8f, "note 1"); 197 Event p1(20, 123.4f, 20, 0.8f, "note 1");
199 Event p2(20, 124.3f, 10, 0.9f, "note 2"); 198 Event p2(20, 124.3f, 10, 0.9f, "note 2");
200 Event p3(50, 126.3f, 30, 0.9f, "note 3"); 199 Event p3(50, 126.3f, 30, 0.9f, "note 3");
201 m.setScaleUnits("Hz"); 200 m.setScaleUnits("Hz");
202 m.addPoint(p1); 201 m.add(p1);
203 m.addPoint(p2); 202 m.add(p2);
204 m.addPoint(p3); 203 m.add(p3);
205 QString xml; 204 QString xml;
206 QTextStream str(&xml, QIODevice::WriteOnly); 205 QTextStream str(&xml, QIODevice::WriteOnly);
207 m.toXml(str); 206 m.toXml(str);
208 str.flush(); 207 str.flush();
209 QString expected = 208 QString expected =