Mercurial > hg > svcore
comparison base/test/TestEventSeries.h @ 1654:26aa42fd60e9 single-point
Add overspill to events-within search
author | Chris Cannam |
---|---|
date | Wed, 20 Mar 2019 11:12:54 +0000 |
parents | eaad70939848 |
children | e4084bc60fe8 |
comparison
equal
deleted
inserted
replaced
1653:eaad70939848 | 1654:26aa42fd60e9 |
---|---|
464 s.add(a); | 464 s.add(a); |
465 s.add(cc); | 465 s.add(cc); |
466 s.add(dd); | 466 s.add(dd); |
467 s.add(e); | 467 s.add(e); |
468 QCOMPARE(s.getEventsWithin(2, 7), EventVector({ b, c, cc })); | 468 QCOMPARE(s.getEventsWithin(2, 7), EventVector({ b, c, cc })); |
469 } | |
470 | |
471 void eventPatternWithinWithOverspill() { | |
472 | |
473 EventSeries s; | |
474 Event a(0, 1.0f, 18, QString("a")); | |
475 Event b(3, 2.0f, 6, QString("b")); | |
476 Event c(5, 3.0f, 2, QString("c")); | |
477 Event cc(5, 3.1f, 2, QString("cc")); | |
478 Event d(6, 4.0f, 10, QString("d")); | |
479 Event dd(6, 4.5f, 10, QString("dd")); | |
480 Event e(14, 5.0f, 3, QString("e")); | |
481 s.add(b); | |
482 s.add(c); | |
483 s.add(d); | |
484 s.add(a); | |
485 s.add(cc); | |
486 s.add(dd); | |
487 s.add(e); | |
488 QCOMPARE(s.getEventsWithin(0, 0, 0), EventVector()); | |
489 QCOMPARE(s.getEventsWithin(0, 0, 1), EventVector({ a })); | |
490 QCOMPARE(s.getEventsWithin(0, 0, 2), EventVector({ a, b })); | |
491 QCOMPARE(s.getEventsWithin(20, 1, 0), EventVector()); | |
492 QCOMPARE(s.getEventsWithin(20, 1, 1), EventVector({ e })); | |
493 QCOMPARE(s.getEventsWithin(20, 1, 2), EventVector({ dd, e })); | |
494 QCOMPARE(s.getEventsWithin(2, 7, 0), EventVector({ b, c, cc })); | |
495 QCOMPARE(s.getEventsWithin(2, 7, 1), EventVector({ a, b, c, cc, d })); | |
496 QCOMPARE(s.getEventsWithin(2, 7, 2), EventVector({ a, b, c, cc, d, dd })); | |
497 QCOMPARE(s.getEventsWithin(2, 7, 3), EventVector({ a, b, c, cc, d, dd, e })); | |
498 QCOMPARE(s.getEventsWithin(2, 7, 4), EventVector({ a, b, c, cc, d, dd, e })); | |
469 } | 499 } |
470 | 500 |
471 void eventPatternStartingWithin() { | 501 void eventPatternStartingWithin() { |
472 | 502 |
473 EventSeries s; | 503 EventSeries s; |
621 void matchingForward() { | 651 void matchingForward() { |
622 | 652 |
623 EventSeries s; | 653 EventSeries s; |
624 Event p; | 654 Event p; |
625 QCOMPARE(s.getNearestEventMatching | 655 QCOMPARE(s.getNearestEventMatching |
626 (6, [](const Event &e) { return e.getDuration() < 4; }, | 656 (6, [](Event e) { return e.getDuration() < 4; }, |
627 EventSeries::Forward, p), false); | 657 EventSeries::Forward, p), false); |
628 Event a(0, 1.0f, 18, QString("a")); | 658 Event a(0, 1.0f, 18, QString("a")); |
629 Event b(3, 2.0f, 6, QString("b")); | 659 Event b(3, 2.0f, 6, QString("b")); |
630 Event c(5, 3.0f, 2, QString("c")); | 660 Event c(5, 3.0f, 2, QString("c")); |
631 Event cc(5, 3.1f, 2, QString("cc")); | 661 Event cc(5, 3.1f, 2, QString("cc")); |
639 s.add(a); | 669 s.add(a); |
640 s.add(cc); | 670 s.add(cc); |
641 s.add(dd); | 671 s.add(dd); |
642 s.add(e); | 672 s.add(e); |
643 QCOMPARE(s.getNearestEventMatching | 673 QCOMPARE(s.getNearestEventMatching |
644 (0, [](const Event &e) { return e.getDuration() < 4; }, | 674 (0, [](Event e) { return e.getDuration() < 4; }, |
645 EventSeries::Forward, p), true); | 675 EventSeries::Forward, p), true); |
646 QCOMPARE(p, c); | 676 QCOMPARE(p, c); |
647 QCOMPARE(s.getNearestEventMatching | 677 QCOMPARE(s.getNearestEventMatching |
648 (6, [](const Event &e) { return e.getDuration() < 4; }, | 678 (6, [](Event e) { return e.getDuration() < 4; }, |
649 EventSeries::Forward, p), true); | 679 EventSeries::Forward, p), true); |
650 QCOMPARE(p, e); | 680 QCOMPARE(p, e); |
651 QCOMPARE(s.getNearestEventMatching | 681 QCOMPARE(s.getNearestEventMatching |
652 (6, [](const Event &e) { return e.getDuration() > 4; }, | 682 (6, [](Event e) { return e.getDuration() > 4; }, |
653 EventSeries::Forward, p), true); | 683 EventSeries::Forward, p), true); |
654 QCOMPARE(p, d); | 684 QCOMPARE(p, d); |
655 QCOMPARE(s.getNearestEventMatching | 685 QCOMPARE(s.getNearestEventMatching |
656 (20, [](const Event &e) { return e.getDuration() > 4; }, | 686 (20, [](Event e) { return e.getDuration() > 4; }, |
657 EventSeries::Forward, p), false); | 687 EventSeries::Forward, p), false); |
658 } | 688 } |
659 | 689 |
660 void matchingBackward() { | 690 void matchingBackward() { |
661 | 691 |
662 EventSeries s; | 692 EventSeries s; |
663 Event p; | 693 Event p; |
664 QCOMPARE(s.getNearestEventMatching | 694 QCOMPARE(s.getNearestEventMatching |
665 (6, [](const Event &e) { return e.getDuration() < 4; }, | 695 (6, [](Event e) { return e.getDuration() < 4; }, |
666 EventSeries::Backward, p), false); | 696 EventSeries::Backward, p), false); |
667 Event a(0, 1.0f, 18, QString("a")); | 697 Event a(0, 1.0f, 18, QString("a")); |
668 Event b(3, 2.0f, 6, QString("b")); | 698 Event b(3, 2.0f, 6, QString("b")); |
669 Event c(5, 3.0f, 2, QString("c")); | 699 Event c(5, 3.0f, 2, QString("c")); |
670 Event cc(5, 3.1f, 2, QString("cc")); | 700 Event cc(5, 3.1f, 2, QString("cc")); |
678 s.add(a); | 708 s.add(a); |
679 s.add(cc); | 709 s.add(cc); |
680 s.add(dd); | 710 s.add(dd); |
681 s.add(e); | 711 s.add(e); |
682 QCOMPARE(s.getNearestEventMatching | 712 QCOMPARE(s.getNearestEventMatching |
683 (0, [](const Event &e) { return e.getDuration() < 4; }, | 713 (0, [](Event e) { return e.getDuration() < 4; }, |
684 EventSeries::Backward, p), false); | 714 EventSeries::Backward, p), false); |
685 QCOMPARE(s.getNearestEventMatching | 715 QCOMPARE(s.getNearestEventMatching |
686 (6, [](const Event &e) { return e.getDuration() > 4; }, | 716 (6, [](Event e) { return e.getDuration() > 4; }, |
687 EventSeries::Backward, p), true); | 717 EventSeries::Backward, p), true); |
688 QCOMPARE(p, b); | 718 QCOMPARE(p, b); |
689 QCOMPARE(s.getNearestEventMatching | 719 QCOMPARE(s.getNearestEventMatching |
690 (20, [](const Event &e) { return e.getDuration() > 4; }, | 720 (20, [](Event e) { return e.getDuration() > 4; }, |
691 EventSeries::Backward, p), true); | 721 EventSeries::Backward, p), true); |
692 QCOMPARE(p, dd); | 722 QCOMPARE(p, dd); |
693 } | 723 } |
694 }; | 724 }; |
695 | 725 |