comparison base/test/TestEventSeries.h @ 1632:0890c10e5129 single-point

Add some more handy methods
author Chris Cannam
date Tue, 12 Mar 2019 14:52:11 +0000
parents f594fd249473
children 6ac92836cd86
comparison
equal deleted inserted replaced
1631:b2048f350906 1632:0890c10e5129
461 s.remove(b); 461 s.remove(b);
462 QCOMPARE(s.getEventsCovering(8), EventVector()); 462 QCOMPARE(s.getEventsCovering(8), EventVector());
463 QCOMPARE(s.count(), 0); 463 QCOMPARE(s.count(), 0);
464 QCOMPARE(s.isEmpty(), true); 464 QCOMPARE(s.isEmpty(), true);
465 } 465 }
466
467 void preceding() {
468
469 EventSeries s;
470 Event a(0, 1.0f, 18, QString("a"));
471 Event b(3, 2.0f, 6, QString("b"));
472 Event c(5, 3.0f, 2, QString("c"));
473 Event cc(5, 3.1f, 2, QString("cc"));
474 Event d(6, 4.0f, 10, QString("d"));
475 Event dd(6, 4.5f, 10, QString("dd"));
476 Event e(14, 5.0f, 3, QString("e"));
477 s.add(b);
478 s.add(c);
479 s.add(d);
480 s.add(a);
481 s.add(cc);
482 s.add(dd);
483 s.add(e);
484 Event p;
485 QCOMPARE(s.getEventPreceding(e, p), true);
486 QCOMPARE(p, dd);
487 QCOMPARE(s.getEventPreceding(p, p), true);
488 QCOMPARE(p, d);
489 QCOMPARE(s.getEventPreceding(p, p), true);
490 QCOMPARE(p, cc);
491 QCOMPARE(s.getEventPreceding(p, p), true);
492 QCOMPARE(p, c);
493 QCOMPARE(s.getEventPreceding(p, p), true);
494 QCOMPARE(p, b);
495 QCOMPARE(s.getEventPreceding(p, p), true);
496 QCOMPARE(p, a);
497 QCOMPARE(s.getEventPreceding(p, p), false);
498 }
499
500 void following() {
501
502 EventSeries s;
503 Event a(0, 1.0f, 18, QString("a"));
504 Event b(3, 2.0f, 6, QString("b"));
505 Event c(5, 3.0f, 2, QString("c"));
506 Event cc(5, 3.1f, 2, QString("cc"));
507 Event d(6, 4.0f, 10, QString("d"));
508 Event dd(6, 4.5f, 10, QString("dd"));
509 Event e(14, 5.0f, 3, QString("e"));
510 s.add(b);
511 s.add(c);
512 s.add(d);
513 s.add(a);
514 s.add(cc);
515 s.add(dd);
516 s.add(e);
517 Event p;
518 QCOMPARE(s.getEventFollowing(a, p), true);
519 QCOMPARE(p, b);
520 QCOMPARE(s.getEventFollowing(p, p), true);
521 QCOMPARE(p, c);
522 QCOMPARE(s.getEventFollowing(p, p), true);
523 QCOMPARE(p, cc);
524 QCOMPARE(s.getEventFollowing(p, p), true);
525 QCOMPARE(p, d);
526 QCOMPARE(s.getEventFollowing(p, p), true);
527 QCOMPARE(p, dd);
528 QCOMPARE(s.getEventFollowing(p, p), true);
529 QCOMPARE(p, e);
530 QCOMPARE(s.getEventFollowing(p, p), false);
531 }
466 }; 532 };
467 533
468 #endif 534 #endif