# HG changeset patch # User Chris Cannam # Date 1552402591 0 # Node ID 6ac92836cd860645daade6ebd1ed2e8492573b62 # Parent 0890c10e512920f7253919188331711e29aea181 Further test & fixes diff -r 0890c10e5129 -r 6ac92836cd86 base/EventSeries.cpp --- a/base/EventSeries.cpp Tue Mar 12 14:52:11 2019 +0000 +++ b/base/EventSeries.cpp Tue Mar 12 14:56:31 2019 +0000 @@ -293,9 +293,11 @@ if (pitr == m_events.end() || *pitr != e) { return false; } - ++pitr; - if (pitr == m_events.end()) { - return false; + while (*pitr == e) { + ++pitr; + if (pitr == m_events.end()) { + return false; + } } following = *pitr; return true; diff -r 0890c10e5129 -r 6ac92836cd86 base/EventSeries.h --- a/base/EventSeries.h Tue Mar 12 14:52:11 2019 +0000 +++ b/base/EventSeries.h Tue Mar 12 14:56:31 2019 +0000 @@ -98,6 +98,8 @@ * If there are multiple events identical to e in the series, * assume that the event passed in is the first one (i.e. never * set preceding equal to e). + * + * It is acceptable for preceding to alias e when this is called. */ bool getEventPreceding(const Event &e, Event &preceding) const; @@ -110,6 +112,8 @@ * If there are multiple events identical to e in the series, * assume that the event passed in is the last one (i.e. never set * following equal to e). + * + * It is acceptable for following to alias e when this is called. */ bool getEventFollowing(const Event &e, Event &following) const; diff -r 0890c10e5129 -r 6ac92836cd86 base/test/TestEventSeries.h --- a/base/test/TestEventSeries.h Tue Mar 12 14:52:11 2019 +0000 +++ b/base/test/TestEventSeries.h Tue Mar 12 14:56:31 2019 +0000 @@ -477,6 +477,7 @@ s.add(b); s.add(c); s.add(d); + s.add(d); // again s.add(a); s.add(cc); s.add(dd); @@ -510,6 +511,7 @@ s.add(b); s.add(c); s.add(d); + s.add(d); // again s.add(a); s.add(cc); s.add(dd);