1 #define BOOST_TEST_MODULE (ClosedRangeSetHandler_t) 2 #include "boost/test/unit_test.hpp" 58 eventRanges(
unsigned const subrun)
60 std::vector<EventRange>
ranges;
62 ranges.emplace_back(0, 5, 11);
63 }
else if (subrun == 1u) {
64 ranges.emplace_back(1, 1, 7);
65 ranges.emplace_back(1, 9, 15);
66 }
else if (subrun == 2u) {
67 ranges.emplace_back(2, 3, 15);
82 std::vector<EventRange> runRanges;
83 for (std::size_t i{0}; i != 3; ++i) {
84 auto const&
ranges = eventRanges(i);
86 srHandlers.push_back(std::make_unique<ClosedRangeSetHandler>(
rs));
90 std::make_unique<ClosedRangeSetHandler>(
RangeSet{1, runRanges});
92 std::vector<std::unique_ptr<RangeSetHandler>>
94 std::unique_ptr<RangeSetHandler>
100 BOOST_FIXTURE_TEST_SUITE(ClosedRangeSetHandler_t, RSHandler)
106 for (std::size_t i{0}; i != 3; ++i) {
107 srHandlers[i]->flushRanges();
109 BOOST_TEST(srHandlers[i]->seenRanges() ==
rs);
112 rHandler->flushRanges();
113 std::vector<EventRange> runRef;
114 for (std::size_t i{0}; i != 3; ++i) {
118 BOOST_TEST(rHandler->seenRanges() == runRSRef);
127 std::vector<SimpleEvent>
events;
128 events.emplace_back(
EventID{1, 1, 3},
false);
129 events.emplace_back(
EventID{1, 1, 4},
false);
130 events.emplace_back(
EventID{1, 1, 5},
false);
132 auto const& srHandler = srHandlers[1];
134 for (
auto const&
e : events) {
135 srHandler->update(
e.id,
e.lastInSubRun);
136 rHandler->update(
e.id,
e.lastInSubRun);
141 srHandler->maybeSplitRange();
142 rHandler->maybeSplitRange();
145 std::vector<EventRange> subRunRef;
146 subRunRef.emplace_back(1, 1, 6);
147 RangeSet const subRunRSRef{1, subRunRef};
148 BOOST_TEST(srHandler->seenRanges() == subRunRSRef);
152 std::vector<EventRange> runRef;
153 runRef.emplace_back(0, 5, 11);
154 runRef.emplace_back(1, 1, 6);
156 BOOST_TEST(rHandler->seenRanges() == runRSRef);
165 srHandler->update(lastEvent.id, lastEvent.lastInSubRun);
166 rHandler->update(lastEvent.id, lastEvent.lastInSubRun);
169 srHandler->flushRanges();
170 rHandler->flushRanges();
172 std::vector<EventRange> subRunRef;
173 subRunRef.emplace_back(1, 6, 7);
174 subRunRef.emplace_back(1, 9, 15);
175 RangeSet const subRunRSRef{1, subRunRef};
176 BOOST_TEST(srHandler->seenRanges() == subRunRSRef);
179 std::vector<EventRange> runRef;
180 runRef.emplace_back(1, 6, 7);
181 runRef.emplace_back(1, 9, 15);
182 runRef.emplace_back(2, 3, 15);
184 BOOST_TEST(rHandler->seenRanges() == runRSRef);
194 std::vector<SimpleEvent>
events;
195 events.emplace_back(
EventID{1, 1, 3},
false);
196 events.emplace_back(
EventID{1, 1, 4},
false);
197 events.emplace_back(
EventID{1, 1, 5},
true);
199 auto const& srHandler = srHandlers[1];
201 for (
auto const&
e : events) {
202 srHandler->update(
e.id,
e.lastInSubRun);
203 rHandler->update(
e.id,
e.lastInSubRun);
207 srHandler->maybeSplitRange();
208 rHandler->maybeSplitRange();
210 RangeSet const subRunRSRef{1, eventRanges(1)};
211 BOOST_TEST(srHandler->seenRanges() == subRunRSRef);
214 std::vector<EventRange> runRef;
218 BOOST_TEST(rHandler->seenRanges() == runRSRef);
225 RangeSet const emptyRS{1, std::vector<EventRange>{}};
226 BOOST_TEST(srHandler->seenRanges() == emptyRS);
227 BOOST_TEST(rHandler->seenRanges() == emptyRS);
230 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(EmptyRunAndSubRuns)
std::string concatenate(H const &h, T const &...t)