Chris@1612
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@1612
|
2
|
Chris@1612
|
3 /*
|
Chris@1612
|
4 Sonic Visualiser
|
Chris@1612
|
5 An audio file viewer and annotation editor.
|
Chris@1612
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@1612
|
7
|
Chris@1612
|
8 This program is free software; you can redistribute it and/or
|
Chris@1612
|
9 modify it under the terms of the GNU General Public License as
|
Chris@1612
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@1612
|
11 License, or (at your option) any later version. See the file
|
Chris@1612
|
12 COPYING included with this distribution for more information.
|
Chris@1612
|
13 */
|
Chris@1612
|
14
|
Chris@1615
|
15 #ifndef TEST_EVENT_SERIES_H
|
Chris@1615
|
16 #define TEST_EVENT_SERIES_H
|
Chris@1612
|
17
|
Chris@1615
|
18 #include "../EventSeries.h"
|
Chris@1612
|
19
|
Chris@1612
|
20 #include <QObject>
|
Chris@1612
|
21 #include <QtTest>
|
Chris@1612
|
22
|
Chris@1612
|
23 #include <iostream>
|
Chris@1612
|
24
|
Chris@1612
|
25 using namespace std;
|
Chris@1612
|
26
|
Chris@1615
|
27 class TestEventSeries : public QObject
|
Chris@1612
|
28 {
|
Chris@1612
|
29 Q_OBJECT
|
Chris@1612
|
30
|
Chris@1612
|
31 private slots:
|
Chris@1612
|
32 void empty() {
|
Chris@1612
|
33
|
Chris@1615
|
34 EventSeries s;
|
Chris@1612
|
35 QCOMPARE(s.isEmpty(), true);
|
Chris@1612
|
36 QCOMPARE(s.count(), 0);
|
Chris@1612
|
37
|
Chris@1615
|
38 Event p(10, QString());
|
Chris@1612
|
39 QCOMPARE(s.contains(p), false);
|
Chris@1616
|
40 QCOMPARE(s.getEventsCovering(400), EventVector());
|
Chris@1612
|
41 }
|
Chris@1612
|
42
|
Chris@1615
|
43 void singleEvent() {
|
Chris@1612
|
44
|
Chris@1615
|
45 EventSeries s;
|
Chris@1615
|
46 Event p(10, QString());
|
Chris@1612
|
47 s.add(p);
|
Chris@1612
|
48 QCOMPARE(s.isEmpty(), false);
|
Chris@1612
|
49 QCOMPARE(s.count(), 1);
|
Chris@1612
|
50 QCOMPARE(s.contains(p), true);
|
Chris@1612
|
51
|
Chris@1612
|
52 s.remove(p);
|
Chris@1612
|
53 QCOMPARE(s.isEmpty(), true);
|
Chris@1616
|
54 QCOMPARE(s.count(), 0);
|
Chris@1612
|
55 QCOMPARE(s.contains(p), false);
|
Chris@1612
|
56 }
|
Chris@1612
|
57
|
Chris@1616
|
58 void duplicateEvents() {
|
Chris@1612
|
59
|
Chris@1615
|
60 EventSeries s;
|
Chris@1615
|
61 Event p(10, QString());
|
Chris@1612
|
62 s.add(p);
|
Chris@1616
|
63 s.add(p);
|
Chris@1616
|
64 QCOMPARE(s.isEmpty(), false);
|
Chris@1616
|
65 QCOMPARE(s.count(), 2);
|
Chris@1616
|
66 QCOMPARE(s.contains(p), true);
|
Chris@1616
|
67
|
Chris@1616
|
68 s.remove(p);
|
Chris@1616
|
69 QCOMPARE(s.isEmpty(), false);
|
Chris@1616
|
70 QCOMPARE(s.count(), 1);
|
Chris@1616
|
71 QCOMPARE(s.contains(p), true);
|
Chris@1616
|
72
|
Chris@1616
|
73 s.remove(p);
|
Chris@1616
|
74 QCOMPARE(s.isEmpty(), true);
|
Chris@1616
|
75 QCOMPARE(s.count(), 0);
|
Chris@1616
|
76 QCOMPARE(s.contains(p), false);
|
Chris@1612
|
77 }
|
Chris@1612
|
78
|
Chris@1616
|
79 void singleEventCover() {
|
Chris@1616
|
80
|
Chris@1616
|
81 EventSeries s;
|
Chris@1616
|
82 Event p(10, QString());
|
Chris@1616
|
83 s.add(p);
|
Chris@1616
|
84 EventVector cover;
|
Chris@1616
|
85 cover.push_back(p);
|
Chris@1616
|
86 QCOMPARE(s.getEventsCovering(10), cover);
|
Chris@1616
|
87 QCOMPARE(s.getEventsCovering(11), EventVector());
|
Chris@1616
|
88 QCOMPARE(s.getEventsCovering(9), EventVector());
|
Chris@1616
|
89 }
|
Chris@1616
|
90
|
Chris@1617
|
91 void singleEventSpan() {
|
Chris@1617
|
92
|
Chris@1617
|
93 EventSeries s;
|
Chris@1617
|
94 Event p(10, QString());
|
Chris@1617
|
95 s.add(p);
|
Chris@1617
|
96 EventVector span;
|
Chris@1617
|
97 span.push_back(p);
|
Chris@1617
|
98 QCOMPARE(s.getEventsSpanning(10, 2), span);
|
Chris@1617
|
99 QCOMPARE(s.getEventsSpanning(9, 2), span);
|
Chris@1617
|
100 QCOMPARE(s.getEventsSpanning(8, 2), EventVector());
|
Chris@1617
|
101 QCOMPARE(s.getEventsSpanning(7, 2), EventVector());
|
Chris@1617
|
102 QCOMPARE(s.getEventsSpanning(11, 2), EventVector());
|
Chris@1617
|
103 }
|
Chris@1617
|
104
|
Chris@1617
|
105 void identicalEventsCover() {
|
Chris@1617
|
106
|
Chris@1617
|
107 EventSeries s;
|
Chris@1617
|
108 Event p(10, QString());
|
Chris@1617
|
109 s.add(p);
|
Chris@1617
|
110 s.add(p);
|
Chris@1617
|
111
|
Chris@1617
|
112 EventVector cover;
|
Chris@1617
|
113 cover.push_back(p);
|
Chris@1617
|
114 cover.push_back(p);
|
Chris@1617
|
115 QCOMPARE(s.getEventsCovering(10), cover);
|
Chris@1617
|
116 QCOMPARE(s.getEventsCovering(11), EventVector());
|
Chris@1617
|
117 QCOMPARE(s.getEventsCovering(9), EventVector());
|
Chris@1617
|
118
|
Chris@1617
|
119 s.remove(p);
|
Chris@1617
|
120 cover.clear();
|
Chris@1617
|
121 cover.push_back(p);
|
Chris@1617
|
122 QCOMPARE(s.getEventsCovering(10), cover);
|
Chris@1617
|
123 QCOMPARE(s.getEventsCovering(11), EventVector());
|
Chris@1617
|
124 QCOMPARE(s.getEventsCovering(9), EventVector());
|
Chris@1617
|
125 }
|
Chris@1617
|
126
|
Chris@1617
|
127 void identicalEventsSpan() {
|
Chris@1617
|
128
|
Chris@1617
|
129 EventSeries s;
|
Chris@1617
|
130 Event p(10, QString());
|
Chris@1617
|
131 s.add(p);
|
Chris@1617
|
132 s.add(p);
|
Chris@1617
|
133
|
Chris@1617
|
134 EventVector span;
|
Chris@1617
|
135 span.push_back(p);
|
Chris@1617
|
136 span.push_back(p);
|
Chris@1617
|
137 QCOMPARE(s.getEventsSpanning(10, 2), span);
|
Chris@1617
|
138 QCOMPARE(s.getEventsSpanning(9, 2), span);
|
Chris@1617
|
139 QCOMPARE(s.getEventsSpanning(8, 2), EventVector());
|
Chris@1617
|
140 QCOMPARE(s.getEventsSpanning(11, 2), EventVector());
|
Chris@1617
|
141 }
|
Chris@1617
|
142
|
Chris@1616
|
143 void similarEventsCover() {
|
Chris@1616
|
144
|
Chris@1616
|
145 EventSeries s;
|
Chris@1616
|
146 Event a(10, QString("a"));
|
Chris@1616
|
147 Event b(10, QString("b"));
|
Chris@1616
|
148 s.add(a);
|
Chris@1616
|
149 s.add(b);
|
Chris@1616
|
150 EventVector cover;
|
Chris@1616
|
151 cover.push_back(a);
|
Chris@1616
|
152 cover.push_back(b);
|
Chris@1616
|
153 QCOMPARE(s.getEventsCovering(10), cover);
|
Chris@1616
|
154 QCOMPARE(s.getEventsCovering(11), EventVector());
|
Chris@1616
|
155 QCOMPARE(s.getEventsCovering(9), EventVector());
|
Chris@1616
|
156 }
|
Chris@1616
|
157
|
Chris@1617
|
158 void similarEventsSpan() {
|
Chris@1617
|
159
|
Chris@1617
|
160 EventSeries s;
|
Chris@1617
|
161 Event a(10, QString("a"));
|
Chris@1617
|
162 Event b(10, QString("b"));
|
Chris@1617
|
163 s.add(a);
|
Chris@1617
|
164 s.add(b);
|
Chris@1617
|
165 EventVector span;
|
Chris@1617
|
166 span.push_back(a);
|
Chris@1617
|
167 span.push_back(b);
|
Chris@1617
|
168 QCOMPARE(s.getEventsSpanning(10, 2), span);
|
Chris@1617
|
169 QCOMPARE(s.getEventsSpanning(9, 2), span);
|
Chris@1617
|
170 QCOMPARE(s.getEventsSpanning(11, 2), EventVector());
|
Chris@1617
|
171 QCOMPARE(s.getEventsSpanning(8, 2), EventVector());
|
Chris@1617
|
172 }
|
Chris@1617
|
173
|
Chris@1616
|
174 void singleEventWithDurationCover() {
|
Chris@1612
|
175
|
Chris@1615
|
176 EventSeries s;
|
Chris@1615
|
177 Event p(10, 1.0, 20, QString());
|
Chris@1612
|
178 s.add(p);
|
Chris@1616
|
179 EventVector cover;
|
Chris@1616
|
180 cover.push_back(p);
|
Chris@1616
|
181 QCOMPARE(s.getEventsCovering(10), cover);
|
Chris@1616
|
182 QCOMPARE(s.getEventsCovering(11), cover);
|
Chris@1616
|
183 QCOMPARE(s.getEventsCovering(29), cover);
|
Chris@1616
|
184 QCOMPARE(s.getEventsCovering(30), EventVector());
|
Chris@1616
|
185 QCOMPARE(s.getEventsCovering(9), EventVector());
|
Chris@1612
|
186 }
|
Chris@1614
|
187
|
Chris@1617
|
188 void singleEventWithDurationSpan() {
|
Chris@1614
|
189
|
Chris@1615
|
190 EventSeries s;
|
Chris@1617
|
191 Event p(10, 1.0, 20, QString());
|
Chris@1614
|
192 s.add(p);
|
Chris@1617
|
193 EventVector span;
|
Chris@1617
|
194 span.push_back(p);
|
Chris@1617
|
195 QCOMPARE(s.getEventsSpanning(9, 2), span);
|
Chris@1617
|
196 QCOMPARE(s.getEventsSpanning(8, 2), EventVector());
|
Chris@1617
|
197 QCOMPARE(s.getEventsSpanning(19, 4), span);
|
Chris@1617
|
198 QCOMPARE(s.getEventsSpanning(29, 2), span);
|
Chris@1617
|
199 QCOMPARE(s.getEventsSpanning(30, 2), EventVector());
|
Chris@1617
|
200 }
|
Chris@1614
|
201
|
Chris@1616
|
202 void identicalEventsWithDurationCover() {
|
Chris@1614
|
203
|
Chris@1615
|
204 EventSeries s;
|
Chris@1615
|
205 Event p(10, 1.0, 20, QString());
|
Chris@1614
|
206 s.add(p);
|
Chris@1614
|
207 s.add(p);
|
Chris@1616
|
208 EventVector cover;
|
Chris@1616
|
209 cover.push_back(p);
|
Chris@1616
|
210 cover.push_back(p);
|
Chris@1616
|
211 QCOMPARE(s.getEventsCovering(10), cover);
|
Chris@1616
|
212 QCOMPARE(s.getEventsCovering(11), cover);
|
Chris@1616
|
213 QCOMPARE(s.getEventsCovering(29), cover);
|
Chris@1616
|
214 QCOMPARE(s.getEventsCovering(30), EventVector());
|
Chris@1616
|
215 QCOMPARE(s.getEventsCovering(9), EventVector());
|
Chris@1614
|
216
|
Chris@1614
|
217 s.remove(p);
|
Chris@1616
|
218 cover.clear();
|
Chris@1616
|
219 cover.push_back(p);
|
Chris@1616
|
220 QCOMPARE(s.getEventsCovering(10), cover);
|
Chris@1616
|
221 QCOMPARE(s.getEventsCovering(11), cover);
|
Chris@1616
|
222 QCOMPARE(s.getEventsCovering(29), cover);
|
Chris@1616
|
223 QCOMPARE(s.getEventsCovering(30), EventVector());
|
Chris@1616
|
224 QCOMPARE(s.getEventsCovering(9), EventVector());
|
Chris@1614
|
225 }
|
Chris@1614
|
226
|
Chris@1617
|
227 void identicalEventsWithDurationSpan() {
|
Chris@1617
|
228
|
Chris@1617
|
229 EventSeries s;
|
Chris@1617
|
230 Event p(10, 1.0, 20, QString());
|
Chris@1617
|
231 s.add(p);
|
Chris@1617
|
232 s.add(p);
|
Chris@1617
|
233 EventVector span;
|
Chris@1617
|
234 span.push_back(p);
|
Chris@1617
|
235 span.push_back(p);
|
Chris@1617
|
236 QCOMPARE(s.getEventsSpanning(9, 2), span);
|
Chris@1617
|
237 QCOMPARE(s.getEventsSpanning(10, 2), span);
|
Chris@1617
|
238 QCOMPARE(s.getEventsSpanning(11, 2), span);
|
Chris@1617
|
239 QCOMPARE(s.getEventsSpanning(29, 2), span);
|
Chris@1617
|
240 QCOMPARE(s.getEventsSpanning(30, 2), EventVector());
|
Chris@1617
|
241 QCOMPARE(s.getEventsSpanning(8, 2), EventVector());
|
Chris@1617
|
242 }
|
Chris@1617
|
243
|
Chris@1616
|
244 void multipleEventsCover() {
|
Chris@1614
|
245
|
Chris@1615
|
246 EventSeries s;
|
Chris@1615
|
247 Event a(10, QString("a"));
|
Chris@1615
|
248 Event b(11, QString("b"));
|
Chris@1615
|
249 Event c(40, QString("c"));
|
Chris@1614
|
250 s.add(c);
|
Chris@1614
|
251 s.add(a);
|
Chris@1614
|
252 s.add(b);
|
Chris@1614
|
253 s.remove(a);
|
Chris@1614
|
254 s.add(a);
|
Chris@1614
|
255 s.add(c);
|
Chris@1614
|
256 s.remove(c);
|
Chris@1614
|
257 QCOMPARE(s.count(), 3);
|
Chris@1616
|
258 EventVector cover;
|
Chris@1616
|
259 cover.push_back(a);
|
Chris@1616
|
260 QCOMPARE(s.getEventsCovering(10), cover);
|
Chris@1616
|
261 cover.clear();
|
Chris@1616
|
262 cover.push_back(c);
|
Chris@1616
|
263 QCOMPARE(s.getEventsCovering(40), cover);
|
Chris@1616
|
264 QCOMPARE(s.getEventsCovering(9), EventVector());
|
Chris@1614
|
265 }
|
Chris@1614
|
266
|
Chris@1617
|
267 void multipleEventsSpan() {
|
Chris@1617
|
268
|
Chris@1617
|
269 EventSeries s;
|
Chris@1617
|
270 Event a(10, QString("a"));
|
Chris@1617
|
271 Event b(11, QString("b"));
|
Chris@1617
|
272 Event c(40, QString("c"));
|
Chris@1617
|
273 s.add(c);
|
Chris@1617
|
274 s.add(a);
|
Chris@1617
|
275 s.add(b);
|
Chris@1617
|
276 EventVector span;
|
Chris@1617
|
277 span.push_back(a);
|
Chris@1617
|
278 span.push_back(b);
|
Chris@1617
|
279 QCOMPARE(s.getEventsSpanning(10, 2), span);
|
Chris@1617
|
280 span.clear();
|
Chris@1617
|
281 span.push_back(c);
|
Chris@1617
|
282 QCOMPARE(s.getEventsSpanning(39, 3), span);
|
Chris@1617
|
283 QCOMPARE(s.getEventsSpanning(9, 1), EventVector());
|
Chris@1617
|
284 QCOMPARE(s.getEventsSpanning(10, 0), EventVector());
|
Chris@1617
|
285 }
|
Chris@1617
|
286
|
Chris@1616
|
287 void disjointEventsWithDurationCover() {
|
Chris@1614
|
288
|
Chris@1615
|
289 EventSeries s;
|
Chris@1615
|
290 Event a(10, 1.0f, 20, QString("a"));
|
Chris@1615
|
291 Event b(100, 1.2f, 30, QString("b"));
|
Chris@1614
|
292 s.add(a);
|
Chris@1614
|
293 s.add(b);
|
Chris@1616
|
294 QCOMPARE(s.getEventsCovering(0), EventVector());
|
Chris@1616
|
295 QCOMPARE(s.getEventsCovering(10), EventVector({ a }));
|
Chris@1616
|
296 QCOMPARE(s.getEventsCovering(15), EventVector({ a }));
|
Chris@1616
|
297 QCOMPARE(s.getEventsCovering(30), EventVector());
|
Chris@1616
|
298 QCOMPARE(s.getEventsCovering(99), EventVector());
|
Chris@1616
|
299 QCOMPARE(s.getEventsCovering(100), EventVector({ b }));
|
Chris@1616
|
300 QCOMPARE(s.getEventsCovering(120), EventVector({ b }));
|
Chris@1616
|
301 QCOMPARE(s.getEventsCovering(130), EventVector());
|
Chris@1614
|
302 }
|
Chris@1614
|
303
|
Chris@1619
|
304 void disjointEventsWithDurationSpan() {
|
Chris@1619
|
305
|
Chris@1619
|
306 EventSeries s;
|
Chris@1619
|
307 Event a(10, 1.0f, 20, QString("a"));
|
Chris@1619
|
308 Event b(100, 1.2f, 30, QString("b"));
|
Chris@1619
|
309 s.add(a);
|
Chris@1619
|
310 s.add(b);
|
Chris@1619
|
311 QCOMPARE(s.getEventsSpanning(0, 10), EventVector());
|
Chris@1619
|
312 QCOMPARE(s.getEventsSpanning(10, 10), EventVector({ a }));
|
Chris@1619
|
313 QCOMPARE(s.getEventsSpanning(15, 85), EventVector({ a }));
|
Chris@1619
|
314 QCOMPARE(s.getEventsSpanning(30, 5), EventVector());
|
Chris@1619
|
315 QCOMPARE(s.getEventsSpanning(99, 1), EventVector());
|
Chris@1619
|
316 QCOMPARE(s.getEventsSpanning(100, 1), EventVector({ b }));
|
Chris@1619
|
317 QCOMPARE(s.getEventsSpanning(120, 20), EventVector({ b }));
|
Chris@1619
|
318 QCOMPARE(s.getEventsSpanning(130, 109), EventVector());
|
Chris@1619
|
319 }
|
Chris@1619
|
320
|
Chris@1616
|
321 void overlappingEventsWithAndWithoutDurationCover() {
|
Chris@1614
|
322
|
Chris@1615
|
323 EventSeries s;
|
Chris@1615
|
324 Event p(20, QString("p"));
|
Chris@1616
|
325 Event a(10, 1.0f, 20, QString("a"));
|
Chris@1614
|
326 s.add(p);
|
Chris@1614
|
327 s.add(a);
|
Chris@1616
|
328 EventVector cover;
|
Chris@1616
|
329 cover.push_back(a);
|
Chris@1616
|
330 QCOMPARE(s.getEventsCovering(15), cover);
|
Chris@1616
|
331 QCOMPARE(s.getEventsCovering(25), cover);
|
Chris@1616
|
332 cover.clear();
|
Chris@1616
|
333 cover.push_back(p);
|
Chris@1616
|
334 cover.push_back(a);
|
Chris@1616
|
335 QCOMPARE(s.getEventsCovering(20), cover);
|
Chris@1614
|
336 }
|
Chris@1619
|
337
|
Chris@1619
|
338 void overlappingEventsWithAndWithoutDurationSpan() {
|
Chris@1619
|
339
|
Chris@1619
|
340 EventSeries s;
|
Chris@1619
|
341 Event p(20, QString("p"));
|
Chris@1619
|
342 Event a(10, 1.0f, 20, QString("a"));
|
Chris@1619
|
343 s.add(p);
|
Chris@1619
|
344 s.add(a);
|
Chris@1619
|
345 EventVector span;
|
Chris@1619
|
346 span.push_back(a);
|
Chris@1619
|
347 QCOMPARE(s.getEventsSpanning(5, 10), span);
|
Chris@1619
|
348 QCOMPARE(s.getEventsSpanning(25, 5), span);
|
Chris@1619
|
349 span.clear();
|
Chris@1619
|
350 span.push_back(p);
|
Chris@1619
|
351 span.push_back(a);
|
Chris@1619
|
352 QCOMPARE(s.getEventsSpanning(20, 1), span);
|
Chris@1619
|
353 }
|
Chris@1614
|
354
|
Chris@1616
|
355 void overlappingEventsWithDurationCover() {
|
Chris@1614
|
356
|
Chris@1615
|
357 EventSeries s;
|
Chris@1616
|
358 Event a(20, 1.0f, 10, QString("a"));
|
Chris@1616
|
359 Event b(10, 1.0f, 20, QString("b"));
|
Chris@1616
|
360 Event c(10, 1.0f, 40, QString("c"));
|
Chris@1614
|
361 s.add(a);
|
Chris@1614
|
362 s.add(b);
|
Chris@1614
|
363 s.add(c);
|
Chris@1616
|
364 QCOMPARE(s.getEventsCovering(10), EventVector({ b, c }));
|
Chris@1616
|
365 QCOMPARE(s.getEventsCovering(20), EventVector({ b, c, a }));
|
Chris@1616
|
366 QCOMPARE(s.getEventsCovering(25), EventVector({ b, c, a }));
|
Chris@1616
|
367 QCOMPARE(s.getEventsCovering(30), EventVector({ c }));
|
Chris@1616
|
368 QCOMPARE(s.getEventsCovering(40), EventVector({ c }));
|
Chris@1616
|
369 QCOMPARE(s.getEventsCovering(50), EventVector());
|
Chris@1614
|
370 }
|
Chris@1614
|
371
|
Chris@1619
|
372 void overlappingEventsWithDurationSpan() {
|
Chris@1619
|
373
|
Chris@1619
|
374 EventSeries s;
|
Chris@1619
|
375 Event a(20, 1.0f, 10, QString("a"));
|
Chris@1619
|
376 Event b(10, 1.0f, 20, QString("b"));
|
Chris@1619
|
377 Event c(10, 1.0f, 40, QString("c"));
|
Chris@1619
|
378 s.add(a);
|
Chris@1619
|
379 s.add(b);
|
Chris@1619
|
380 s.add(c);
|
Chris@1619
|
381 QCOMPARE(s.getEventsSpanning(10, 5), EventVector({ b, c }));
|
Chris@1619
|
382 QCOMPARE(s.getEventsSpanning(20, 15), EventVector({ b, c, a }));
|
Chris@1619
|
383 QCOMPARE(s.getEventsSpanning(0, 100), EventVector({ b, c, a }));
|
Chris@1619
|
384 QCOMPARE(s.getEventsSpanning(25, 4), EventVector({ b, c, a }));
|
Chris@1619
|
385 QCOMPARE(s.getEventsSpanning(30, 4), EventVector({ c }));
|
Chris@1619
|
386 QCOMPARE(s.getEventsSpanning(40, 15), EventVector({ c }));
|
Chris@1619
|
387 QCOMPARE(s.getEventsSpanning(50, 10), EventVector());
|
Chris@1619
|
388 }
|
Chris@1619
|
389
|
Chris@1616
|
390 void eventPatternCover() {
|
Chris@1614
|
391
|
Chris@1615
|
392 EventSeries s;
|
Chris@1616
|
393 Event a(0, 1.0f, 18, QString("a"));
|
Chris@1616
|
394 Event b(3, 2.0f, 6, QString("b"));
|
Chris@1616
|
395 Event c(5, 3.0f, 2, QString("c"));
|
Chris@1616
|
396 Event cc(5, 3.1f, 2, QString("cc"));
|
Chris@1616
|
397 Event d(6, 4.0f, 10, QString("d"));
|
Chris@1616
|
398 Event dd(6, 4.5f, 10, QString("dd"));
|
Chris@1616
|
399 Event e(14, 5.0f, 3, QString("e"));
|
Chris@1614
|
400 s.add(b);
|
Chris@1614
|
401 s.add(c);
|
Chris@1614
|
402 s.add(d);
|
Chris@1614
|
403 s.add(a);
|
Chris@1616
|
404 s.add(cc);
|
Chris@1616
|
405 s.add(dd);
|
Chris@1614
|
406 s.add(e);
|
Chris@1616
|
407 QCOMPARE(s.getEventsCovering(8), EventVector({ a, b, d, dd }));
|
Chris@1616
|
408 }
|
Chris@1616
|
409
|
Chris@1619
|
410 void eventPatternSpan() {
|
Chris@1619
|
411
|
Chris@1619
|
412 EventSeries s;
|
Chris@1619
|
413 Event a(0, 1.0f, 18, QString("a"));
|
Chris@1619
|
414 Event b(3, 2.0f, 6, QString("b"));
|
Chris@1619
|
415 Event c(5, 3.0f, 2, QString("c"));
|
Chris@1619
|
416 Event cc(5, 3.1f, 2, QString("cc"));
|
Chris@1619
|
417 Event d(6, 4.0f, 10, QString("d"));
|
Chris@1619
|
418 Event dd(6, 4.5f, 10, QString("dd"));
|
Chris@1619
|
419 Event e(14, 5.0f, 3, QString("e"));
|
Chris@1619
|
420 s.add(b);
|
Chris@1619
|
421 s.add(c);
|
Chris@1619
|
422 s.add(d);
|
Chris@1619
|
423 s.add(a);
|
Chris@1619
|
424 s.add(cc);
|
Chris@1619
|
425 s.add(dd);
|
Chris@1619
|
426 s.add(e);
|
Chris@1619
|
427 QCOMPARE(s.getEventsSpanning(6, 2), EventVector({ a, b, c, cc, d, dd }));
|
Chris@1619
|
428 }
|
Chris@1619
|
429
|
Chris@1616
|
430 void eventPatternAddRemove() {
|
Chris@1616
|
431
|
Chris@1616
|
432 // This is mostly here to exercise the innards of EventSeries
|
Chris@1616
|
433 // and check it doesn't crash out with any internal
|
Chris@1616
|
434 // consistency problems
|
Chris@1616
|
435
|
Chris@1616
|
436 EventSeries s;
|
Chris@1616
|
437 Event a(0, 1.0f, 18, QString("a"));
|
Chris@1616
|
438 Event b(3, 2.0f, 6, QString("b"));
|
Chris@1616
|
439 Event c(5, 3.0f, 2, QString("c"));
|
Chris@1616
|
440 Event cc(5, 3.1f, 2, QString("cc"));
|
Chris@1616
|
441 Event d(6, 4.0f, 10, QString("d"));
|
Chris@1616
|
442 Event dd(6, 4.5f, 10, QString("dd"));
|
Chris@1616
|
443 Event e(14, 5.0f, 3, QString("e"));
|
Chris@1616
|
444 s.add(b);
|
Chris@1616
|
445 s.add(c);
|
Chris@1616
|
446 s.add(d);
|
Chris@1616
|
447 s.add(a);
|
Chris@1616
|
448 s.add(cc);
|
Chris@1616
|
449 s.add(dd);
|
Chris@1616
|
450 s.add(e);
|
Chris@1616
|
451 QCOMPARE(s.count(), 7);
|
Chris@1616
|
452 s.remove(d);
|
Chris@1616
|
453 QCOMPARE(s.getEventsCovering(8), EventVector({ a, b, dd }));
|
Chris@1616
|
454 s.remove(e);
|
Chris@1616
|
455 s.remove(a);
|
Chris@1616
|
456 QCOMPARE(s.getEventsCovering(8), EventVector({ b, dd }));
|
Chris@1616
|
457 s.remove(cc);
|
Chris@1616
|
458 s.remove(c);
|
Chris@1616
|
459 s.remove(dd);
|
Chris@1616
|
460 QCOMPARE(s.getEventsCovering(8), EventVector({ b }));
|
Chris@1616
|
461 s.remove(b);
|
Chris@1616
|
462 QCOMPARE(s.getEventsCovering(8), EventVector());
|
Chris@1616
|
463 QCOMPARE(s.count(), 0);
|
Chris@1616
|
464 QCOMPARE(s.isEmpty(), true);
|
Chris@1614
|
465 }
|
Chris@1632
|
466
|
Chris@1632
|
467 void preceding() {
|
Chris@1632
|
468
|
Chris@1632
|
469 EventSeries s;
|
Chris@1632
|
470 Event a(0, 1.0f, 18, QString("a"));
|
Chris@1632
|
471 Event b(3, 2.0f, 6, QString("b"));
|
Chris@1632
|
472 Event c(5, 3.0f, 2, QString("c"));
|
Chris@1632
|
473 Event cc(5, 3.1f, 2, QString("cc"));
|
Chris@1632
|
474 Event d(6, 4.0f, 10, QString("d"));
|
Chris@1632
|
475 Event dd(6, 4.5f, 10, QString("dd"));
|
Chris@1632
|
476 Event e(14, 5.0f, 3, QString("e"));
|
Chris@1632
|
477 s.add(b);
|
Chris@1632
|
478 s.add(c);
|
Chris@1632
|
479 s.add(d);
|
Chris@1632
|
480 s.add(a);
|
Chris@1632
|
481 s.add(cc);
|
Chris@1632
|
482 s.add(dd);
|
Chris@1632
|
483 s.add(e);
|
Chris@1632
|
484 Event p;
|
Chris@1632
|
485 QCOMPARE(s.getEventPreceding(e, p), true);
|
Chris@1632
|
486 QCOMPARE(p, dd);
|
Chris@1632
|
487 QCOMPARE(s.getEventPreceding(p, p), true);
|
Chris@1632
|
488 QCOMPARE(p, d);
|
Chris@1632
|
489 QCOMPARE(s.getEventPreceding(p, p), true);
|
Chris@1632
|
490 QCOMPARE(p, cc);
|
Chris@1632
|
491 QCOMPARE(s.getEventPreceding(p, p), true);
|
Chris@1632
|
492 QCOMPARE(p, c);
|
Chris@1632
|
493 QCOMPARE(s.getEventPreceding(p, p), true);
|
Chris@1632
|
494 QCOMPARE(p, b);
|
Chris@1632
|
495 QCOMPARE(s.getEventPreceding(p, p), true);
|
Chris@1632
|
496 QCOMPARE(p, a);
|
Chris@1632
|
497 QCOMPARE(s.getEventPreceding(p, p), false);
|
Chris@1632
|
498 }
|
Chris@1632
|
499
|
Chris@1632
|
500 void following() {
|
Chris@1632
|
501
|
Chris@1632
|
502 EventSeries s;
|
Chris@1632
|
503 Event a(0, 1.0f, 18, QString("a"));
|
Chris@1632
|
504 Event b(3, 2.0f, 6, QString("b"));
|
Chris@1632
|
505 Event c(5, 3.0f, 2, QString("c"));
|
Chris@1632
|
506 Event cc(5, 3.1f, 2, QString("cc"));
|
Chris@1632
|
507 Event d(6, 4.0f, 10, QString("d"));
|
Chris@1632
|
508 Event dd(6, 4.5f, 10, QString("dd"));
|
Chris@1632
|
509 Event e(14, 5.0f, 3, QString("e"));
|
Chris@1632
|
510 s.add(b);
|
Chris@1632
|
511 s.add(c);
|
Chris@1632
|
512 s.add(d);
|
Chris@1632
|
513 s.add(a);
|
Chris@1632
|
514 s.add(cc);
|
Chris@1632
|
515 s.add(dd);
|
Chris@1632
|
516 s.add(e);
|
Chris@1632
|
517 Event p;
|
Chris@1632
|
518 QCOMPARE(s.getEventFollowing(a, p), true);
|
Chris@1632
|
519 QCOMPARE(p, b);
|
Chris@1632
|
520 QCOMPARE(s.getEventFollowing(p, p), true);
|
Chris@1632
|
521 QCOMPARE(p, c);
|
Chris@1632
|
522 QCOMPARE(s.getEventFollowing(p, p), true);
|
Chris@1632
|
523 QCOMPARE(p, cc);
|
Chris@1632
|
524 QCOMPARE(s.getEventFollowing(p, p), true);
|
Chris@1632
|
525 QCOMPARE(p, d);
|
Chris@1632
|
526 QCOMPARE(s.getEventFollowing(p, p), true);
|
Chris@1632
|
527 QCOMPARE(p, dd);
|
Chris@1632
|
528 QCOMPARE(s.getEventFollowing(p, p), true);
|
Chris@1632
|
529 QCOMPARE(p, e);
|
Chris@1632
|
530 QCOMPARE(s.getEventFollowing(p, p), false);
|
Chris@1632
|
531 }
|
Chris@1612
|
532 };
|
Chris@1612
|
533
|
Chris@1612
|
534 #endif
|