Mercurial > hg > svcore
diff base/test/TestEventSeries.h @ 1617:bdc19a09a1f9 single-point
Minor tweaks, comments, span tests
author | Chris Cannam |
---|---|
date | Fri, 08 Mar 2019 11:15:59 +0000 |
parents | de446dd905e6 |
children | f594fd249473 |
line wrap: on
line diff
--- a/base/test/TestEventSeries.h Fri Mar 08 10:16:12 2019 +0000 +++ b/base/test/TestEventSeries.h Fri Mar 08 11:15:59 2019 +0000 @@ -88,6 +88,58 @@ QCOMPARE(s.getEventsCovering(9), EventVector()); } + void singleEventSpan() { + + EventSeries s; + Event p(10, QString()); + s.add(p); + EventVector span; + span.push_back(p); + QCOMPARE(s.getEventsSpanning(10, 2), span); + QCOMPARE(s.getEventsSpanning(9, 2), span); + QCOMPARE(s.getEventsSpanning(8, 2), EventVector()); + QCOMPARE(s.getEventsSpanning(7, 2), EventVector()); + QCOMPARE(s.getEventsSpanning(11, 2), EventVector()); + } + + void identicalEventsCover() { + + EventSeries s; + Event p(10, QString()); + s.add(p); + s.add(p); + + EventVector cover; + cover.push_back(p); + cover.push_back(p); + QCOMPARE(s.getEventsCovering(10), cover); + QCOMPARE(s.getEventsCovering(11), EventVector()); + QCOMPARE(s.getEventsCovering(9), EventVector()); + + s.remove(p); + cover.clear(); + cover.push_back(p); + QCOMPARE(s.getEventsCovering(10), cover); + QCOMPARE(s.getEventsCovering(11), EventVector()); + QCOMPARE(s.getEventsCovering(9), EventVector()); + } + + void identicalEventsSpan() { + + EventSeries s; + Event p(10, QString()); + s.add(p); + s.add(p); + + EventVector span; + span.push_back(p); + span.push_back(p); + QCOMPARE(s.getEventsSpanning(10, 2), span); + QCOMPARE(s.getEventsSpanning(9, 2), span); + QCOMPARE(s.getEventsSpanning(8, 2), EventVector()); + QCOMPARE(s.getEventsSpanning(11, 2), EventVector()); + } + void similarEventsCover() { EventSeries s; @@ -103,6 +155,22 @@ QCOMPARE(s.getEventsCovering(9), EventVector()); } + void similarEventsSpan() { + + EventSeries s; + Event a(10, QString("a")); + Event b(10, QString("b")); + s.add(a); + s.add(b); + EventVector span; + span.push_back(a); + span.push_back(b); + QCOMPARE(s.getEventsSpanning(10, 2), span); + QCOMPARE(s.getEventsSpanning(9, 2), span); + QCOMPARE(s.getEventsSpanning(11, 2), EventVector()); + QCOMPARE(s.getEventsSpanning(8, 2), EventVector()); + } + void singleEventWithDurationCover() { EventSeries s; @@ -117,28 +185,20 @@ QCOMPARE(s.getEventsCovering(9), EventVector()); } - void identicalEventsCover() { + void singleEventWithDurationSpan() { EventSeries s; - Event p(10, QString()); + Event p(10, 1.0, 20, QString()); s.add(p); - s.add(p); + EventVector span; + span.push_back(p); + QCOMPARE(s.getEventsSpanning(9, 2), span); + QCOMPARE(s.getEventsSpanning(8, 2), EventVector()); + QCOMPARE(s.getEventsSpanning(19, 4), span); + QCOMPARE(s.getEventsSpanning(29, 2), span); + QCOMPARE(s.getEventsSpanning(30, 2), EventVector()); + } - EventVector cover; - cover.push_back(p); - cover.push_back(p); - QCOMPARE(s.getEventsCovering(10), cover); - QCOMPARE(s.getEventsCovering(11), EventVector()); - QCOMPARE(s.getEventsCovering(9), EventVector()); - - s.remove(p); - cover.clear(); - cover.push_back(p); - QCOMPARE(s.getEventsCovering(10), cover); - QCOMPARE(s.getEventsCovering(11), EventVector()); - QCOMPARE(s.getEventsCovering(9), EventVector()); - } - void identicalEventsWithDurationCover() { EventSeries s; @@ -164,6 +224,23 @@ QCOMPARE(s.getEventsCovering(9), EventVector()); } + void identicalEventsWithDurationSpan() { + + EventSeries s; + Event p(10, 1.0, 20, QString()); + s.add(p); + s.add(p); + EventVector span; + span.push_back(p); + span.push_back(p); + QCOMPARE(s.getEventsSpanning(9, 2), span); + QCOMPARE(s.getEventsSpanning(10, 2), span); + QCOMPARE(s.getEventsSpanning(11, 2), span); + QCOMPARE(s.getEventsSpanning(29, 2), span); + QCOMPARE(s.getEventsSpanning(30, 2), EventVector()); + QCOMPARE(s.getEventsSpanning(8, 2), EventVector()); + } + void multipleEventsCover() { EventSeries s; @@ -187,6 +264,26 @@ QCOMPARE(s.getEventsCovering(9), EventVector()); } + void multipleEventsSpan() { + + EventSeries s; + Event a(10, QString("a")); + Event b(11, QString("b")); + Event c(40, QString("c")); + s.add(c); + s.add(a); + s.add(b); + EventVector span; + span.push_back(a); + span.push_back(b); + QCOMPARE(s.getEventsSpanning(10, 2), span); + span.clear(); + span.push_back(c); + QCOMPARE(s.getEventsSpanning(39, 3), span); + QCOMPARE(s.getEventsSpanning(9, 1), EventVector()); + QCOMPARE(s.getEventsSpanning(10, 0), EventVector()); + } + void disjointEventsWithDurationCover() { EventSeries s;