Mercurial > hg > svcore
comparison base/test/TestEventSeries.h @ 1619:f594fd249473 single-point
Further tests
author | Chris Cannam |
---|---|
date | Fri, 08 Mar 2019 12:59:32 +0000 |
parents | bdc19a09a1f9 |
children | 0890c10e5129 |
comparison
equal
deleted
inserted
replaced
1618:ba3ddb7fe2bd | 1619:f594fd249473 |
---|---|
299 QCOMPARE(s.getEventsCovering(100), EventVector({ b })); | 299 QCOMPARE(s.getEventsCovering(100), EventVector({ b })); |
300 QCOMPARE(s.getEventsCovering(120), EventVector({ b })); | 300 QCOMPARE(s.getEventsCovering(120), EventVector({ b })); |
301 QCOMPARE(s.getEventsCovering(130), EventVector()); | 301 QCOMPARE(s.getEventsCovering(130), EventVector()); |
302 } | 302 } |
303 | 303 |
304 void disjointEventsWithDurationSpan() { | |
305 | |
306 EventSeries s; | |
307 Event a(10, 1.0f, 20, QString("a")); | |
308 Event b(100, 1.2f, 30, QString("b")); | |
309 s.add(a); | |
310 s.add(b); | |
311 QCOMPARE(s.getEventsSpanning(0, 10), EventVector()); | |
312 QCOMPARE(s.getEventsSpanning(10, 10), EventVector({ a })); | |
313 QCOMPARE(s.getEventsSpanning(15, 85), EventVector({ a })); | |
314 QCOMPARE(s.getEventsSpanning(30, 5), EventVector()); | |
315 QCOMPARE(s.getEventsSpanning(99, 1), EventVector()); | |
316 QCOMPARE(s.getEventsSpanning(100, 1), EventVector({ b })); | |
317 QCOMPARE(s.getEventsSpanning(120, 20), EventVector({ b })); | |
318 QCOMPARE(s.getEventsSpanning(130, 109), EventVector()); | |
319 } | |
320 | |
304 void overlappingEventsWithAndWithoutDurationCover() { | 321 void overlappingEventsWithAndWithoutDurationCover() { |
305 | 322 |
306 EventSeries s; | 323 EventSeries s; |
307 Event p(20, QString("p")); | 324 Event p(20, QString("p")); |
308 Event a(10, 1.0f, 20, QString("a")); | 325 Event a(10, 1.0f, 20, QString("a")); |
314 QCOMPARE(s.getEventsCovering(25), cover); | 331 QCOMPARE(s.getEventsCovering(25), cover); |
315 cover.clear(); | 332 cover.clear(); |
316 cover.push_back(p); | 333 cover.push_back(p); |
317 cover.push_back(a); | 334 cover.push_back(a); |
318 QCOMPARE(s.getEventsCovering(20), cover); | 335 QCOMPARE(s.getEventsCovering(20), cover); |
336 } | |
337 | |
338 void overlappingEventsWithAndWithoutDurationSpan() { | |
339 | |
340 EventSeries s; | |
341 Event p(20, QString("p")); | |
342 Event a(10, 1.0f, 20, QString("a")); | |
343 s.add(p); | |
344 s.add(a); | |
345 EventVector span; | |
346 span.push_back(a); | |
347 QCOMPARE(s.getEventsSpanning(5, 10), span); | |
348 QCOMPARE(s.getEventsSpanning(25, 5), span); | |
349 span.clear(); | |
350 span.push_back(p); | |
351 span.push_back(a); | |
352 QCOMPARE(s.getEventsSpanning(20, 1), span); | |
319 } | 353 } |
320 | 354 |
321 void overlappingEventsWithDurationCover() { | 355 void overlappingEventsWithDurationCover() { |
322 | 356 |
323 EventSeries s; | 357 EventSeries s; |
331 QCOMPARE(s.getEventsCovering(20), EventVector({ b, c, a })); | 365 QCOMPARE(s.getEventsCovering(20), EventVector({ b, c, a })); |
332 QCOMPARE(s.getEventsCovering(25), EventVector({ b, c, a })); | 366 QCOMPARE(s.getEventsCovering(25), EventVector({ b, c, a })); |
333 QCOMPARE(s.getEventsCovering(30), EventVector({ c })); | 367 QCOMPARE(s.getEventsCovering(30), EventVector({ c })); |
334 QCOMPARE(s.getEventsCovering(40), EventVector({ c })); | 368 QCOMPARE(s.getEventsCovering(40), EventVector({ c })); |
335 QCOMPARE(s.getEventsCovering(50), EventVector()); | 369 QCOMPARE(s.getEventsCovering(50), EventVector()); |
370 } | |
371 | |
372 void overlappingEventsWithDurationSpan() { | |
373 | |
374 EventSeries s; | |
375 Event a(20, 1.0f, 10, QString("a")); | |
376 Event b(10, 1.0f, 20, QString("b")); | |
377 Event c(10, 1.0f, 40, QString("c")); | |
378 s.add(a); | |
379 s.add(b); | |
380 s.add(c); | |
381 QCOMPARE(s.getEventsSpanning(10, 5), EventVector({ b, c })); | |
382 QCOMPARE(s.getEventsSpanning(20, 15), EventVector({ b, c, a })); | |
383 QCOMPARE(s.getEventsSpanning(0, 100), EventVector({ b, c, a })); | |
384 QCOMPARE(s.getEventsSpanning(25, 4), EventVector({ b, c, a })); | |
385 QCOMPARE(s.getEventsSpanning(30, 4), EventVector({ c })); | |
386 QCOMPARE(s.getEventsSpanning(40, 15), EventVector({ c })); | |
387 QCOMPARE(s.getEventsSpanning(50, 10), EventVector()); | |
336 } | 388 } |
337 | 389 |
338 void eventPatternCover() { | 390 void eventPatternCover() { |
339 | 391 |
340 EventSeries s; | 392 EventSeries s; |
351 s.add(a); | 403 s.add(a); |
352 s.add(cc); | 404 s.add(cc); |
353 s.add(dd); | 405 s.add(dd); |
354 s.add(e); | 406 s.add(e); |
355 QCOMPARE(s.getEventsCovering(8), EventVector({ a, b, d, dd })); | 407 QCOMPARE(s.getEventsCovering(8), EventVector({ a, b, d, dd })); |
408 } | |
409 | |
410 void eventPatternSpan() { | |
411 | |
412 EventSeries s; | |
413 Event a(0, 1.0f, 18, QString("a")); | |
414 Event b(3, 2.0f, 6, QString("b")); | |
415 Event c(5, 3.0f, 2, QString("c")); | |
416 Event cc(5, 3.1f, 2, QString("cc")); | |
417 Event d(6, 4.0f, 10, QString("d")); | |
418 Event dd(6, 4.5f, 10, QString("dd")); | |
419 Event e(14, 5.0f, 3, QString("e")); | |
420 s.add(b); | |
421 s.add(c); | |
422 s.add(d); | |
423 s.add(a); | |
424 s.add(cc); | |
425 s.add(dd); | |
426 s.add(e); | |
427 QCOMPARE(s.getEventsSpanning(6, 2), EventVector({ a, b, c, cc, d, dd })); | |
356 } | 428 } |
357 | 429 |
358 void eventPatternAddRemove() { | 430 void eventPatternAddRemove() { |
359 | 431 |
360 // This is mostly here to exercise the innards of EventSeries | 432 // This is mostly here to exercise the innards of EventSeries |