Mercurial > hg > svcore
comparison base/test/TestEventSeries.h @ 1653:eaad70939848 single-point
Add nearest-event-matching search
author | Chris Cannam |
---|---|
date | Tue, 19 Mar 2019 14:24:05 +0000 |
parents | e7f557789f99 |
children | 26aa42fd60e9 |
comparison
equal
deleted
inserted
replaced
1652:08bed13d3a26 | 1653:eaad70939848 |
---|---|
615 QCOMPARE(p, dd); | 615 QCOMPARE(p, dd); |
616 QCOMPARE(s.getEventFollowing(p, p), true); | 616 QCOMPARE(s.getEventFollowing(p, p), true); |
617 QCOMPARE(p, e); | 617 QCOMPARE(p, e); |
618 QCOMPARE(s.getEventFollowing(p, p), false); | 618 QCOMPARE(s.getEventFollowing(p, p), false); |
619 } | 619 } |
620 | |
621 void matchingForward() { | |
622 | |
623 EventSeries s; | |
624 Event p; | |
625 QCOMPARE(s.getNearestEventMatching | |
626 (6, [](const Event &e) { return e.getDuration() < 4; }, | |
627 EventSeries::Forward, p), false); | |
628 Event a(0, 1.0f, 18, QString("a")); | |
629 Event b(3, 2.0f, 6, QString("b")); | |
630 Event c(5, 3.0f, 2, QString("c")); | |
631 Event cc(5, 3.1f, 2, QString("cc")); | |
632 Event d(6, 4.0f, 10, QString("d")); | |
633 Event dd(6, 4.5f, 10, QString("dd")); | |
634 Event e(14, 5.0f, 3, QString("e")); | |
635 s.add(b); | |
636 s.add(c); | |
637 s.add(d); | |
638 s.add(d); // again | |
639 s.add(a); | |
640 s.add(cc); | |
641 s.add(dd); | |
642 s.add(e); | |
643 QCOMPARE(s.getNearestEventMatching | |
644 (0, [](const Event &e) { return e.getDuration() < 4; }, | |
645 EventSeries::Forward, p), true); | |
646 QCOMPARE(p, c); | |
647 QCOMPARE(s.getNearestEventMatching | |
648 (6, [](const Event &e) { return e.getDuration() < 4; }, | |
649 EventSeries::Forward, p), true); | |
650 QCOMPARE(p, e); | |
651 QCOMPARE(s.getNearestEventMatching | |
652 (6, [](const Event &e) { return e.getDuration() > 4; }, | |
653 EventSeries::Forward, p), true); | |
654 QCOMPARE(p, d); | |
655 QCOMPARE(s.getNearestEventMatching | |
656 (20, [](const Event &e) { return e.getDuration() > 4; }, | |
657 EventSeries::Forward, p), false); | |
658 } | |
659 | |
660 void matchingBackward() { | |
661 | |
662 EventSeries s; | |
663 Event p; | |
664 QCOMPARE(s.getNearestEventMatching | |
665 (6, [](const Event &e) { return e.getDuration() < 4; }, | |
666 EventSeries::Backward, p), false); | |
667 Event a(0, 1.0f, 18, QString("a")); | |
668 Event b(3, 2.0f, 6, QString("b")); | |
669 Event c(5, 3.0f, 2, QString("c")); | |
670 Event cc(5, 3.1f, 2, QString("cc")); | |
671 Event d(6, 4.0f, 10, QString("d")); | |
672 Event dd(6, 4.5f, 10, QString("dd")); | |
673 Event e(14, 5.0f, 3, QString("e")); | |
674 s.add(b); | |
675 s.add(c); | |
676 s.add(d); | |
677 s.add(d); // again | |
678 s.add(a); | |
679 s.add(cc); | |
680 s.add(dd); | |
681 s.add(e); | |
682 QCOMPARE(s.getNearestEventMatching | |
683 (0, [](const Event &e) { return e.getDuration() < 4; }, | |
684 EventSeries::Backward, p), false); | |
685 QCOMPARE(s.getNearestEventMatching | |
686 (6, [](const Event &e) { return e.getDuration() > 4; }, | |
687 EventSeries::Backward, p), true); | |
688 QCOMPARE(p, b); | |
689 QCOMPARE(s.getNearestEventMatching | |
690 (20, [](const Event &e) { return e.getDuration() > 4; }, | |
691 EventSeries::Backward, p), true); | |
692 QCOMPARE(p, dd); | |
693 } | |
620 }; | 694 }; |
621 | 695 |
622 #endif | 696 #endif |