1 #define BOOST_TEST_MODULE (RangeSet_t) 2 #include "boost/test/unit_test.hpp" 14 BOOST_AUTO_TEST_SUITE(RangeSet_t)
19 BOOST_TEST(
rs.empty());
20 BOOST_TEST(
rs.has_disjoint_ranges());
21 BOOST_TEST(
rs.is_sorted());
34 rs.emplace_range(1, 2, 2);
35 rs.emplace_range(1, 7, 7);
36 rs.emplace_range(1, 7, 7);
37 BOOST_TEST(
rs.empty());
42 auto rs = RangeSet::forRun(
RunID{72});
43 BOOST_TEST(!
rs.empty());
44 BOOST_TEST(
rs.has_disjoint_ranges());
45 BOOST_TEST(
rs.is_valid());
46 BOOST_TEST(
rs.is_sorted());
47 BOOST_TEST(
rs.is_collapsed());
48 BOOST_TEST(
rs.is_full_run());
49 std::ostringstream oss;
51 BOOST_TEST(oss.str() ==
" Run: 72 (full run)"s);
56 auto const rs1 = RangeSet::forRun(
RunID{1});
57 auto const rs2 = RangeSet::forRun(
RunID{2});
59 BOOST_TEST(rs1.is_full_run());
60 BOOST_TEST(rs2.is_full_run());
61 BOOST_TEST(rs1.has_disjoint_ranges());
62 BOOST_TEST(rs2.has_disjoint_ranges());
70 auto const rs2 = RangeSet::forRun(
RunID{1});
72 BOOST_TEST(!rs1.is_full_run());
73 BOOST_TEST(rs2.is_full_run());
74 BOOST_TEST(rs1.has_disjoint_ranges());
75 BOOST_TEST(rs2.has_disjoint_ranges());
85 auto const rs2 = RangeSet::forRun(
RunID{1});
86 BOOST_TEST(rs1 == rs2);
92 rs.emplace_range(1, 2, 7);
93 rs.emplace_range(1, 9, 14);
94 BOOST_TEST(
rs.has_disjoint_ranges());
95 BOOST_TEST(
rs.is_sorted());
96 BOOST_TEST(!
rs.is_full_run());
103 rs1.emplace_range(1, 9, 14);
104 rs1.emplace_range(3, 1, 8);
105 rs1.emplace_range(4, 5, 8);
106 BOOST_TEST(rs1.has_disjoint_ranges());
107 BOOST_TEST(rs1.is_sorted());
111 rs2.emplace_range(1, 14, 101);
112 rs2.emplace_range(2, 14, 101);
113 rs2.emplace_range(4, 1, 5);
114 BOOST_TEST(rs2.has_disjoint_ranges());
115 BOOST_TEST(rs2.is_sorted());
123 rs.emplace_range(1, 1, 4);
124 rs.emplace_range(1, 4, 6);
125 rs.emplace_range(1, 6, 11);
126 rs.emplace_range(1, 11, 101);
127 BOOST_TEST(
rs.ranges().size() == 4u);
129 BOOST_TEST(
rs.ranges().size() == 1u);
130 BOOST_TEST(
rs.front().begin() == 1u);
131 BOOST_TEST(
rs.front().end() == 101u);
132 BOOST_TEST(
rs.has_disjoint_ranges());
138 rs.emplace_range(1, 1, 4);
139 rs.emplace_range(1, 1, 11);
140 rs.emplace_range(1, 4, 11);
141 BOOST_TEST(
rs.is_sorted());
142 BOOST_CHECK_EXCEPTION(
151 rs.emplace_range(1, 2, 7);
152 rs.emplace_range(1, 9, 14);
153 rs.split_range(1, 4);
156 ref.emplace_range(1, 4, 7);
157 ref.emplace_range(1, 9, 14);
158 BOOST_TEST(
rs == ref);
164 rs.emplace_range(1, 2, 7);
165 rs.emplace_range(1, 9, 14);
167 rs.split_range(1, 7);
169 rs.split_range(2, 7);
170 BOOST_TEST(split_range1.first ==
rs.end_idx());
171 BOOST_TEST(split_range2.first ==
rs.end_idx());
172 BOOST_TEST(!split_range1.second);
173 BOOST_TEST(!split_range2.second);
179 rs.emplace_range(1, 2, 3);
180 auto split_range1 =
rs.split_range(1, 2);
181 auto split_range2 =
rs.split_range(1, 3);
182 BOOST_TEST(split_range1.first ==
rs.end_idx());
183 BOOST_TEST(split_range2.first ==
185 BOOST_TEST(!split_range1.second);
186 BOOST_TEST(!split_range2.second);
192 rs.emplace_range(1, 2, 7);
193 rs.emplace_range(1, 9, 14);
194 rs.split_range(1, 4);
197 BOOST_TEST(
rs == ref);
205 rs1.emplace_range(1, 4, 8);
212 rs2.emplace_range(1, 8, 11);
218 BOOST_TEST(rs1.ranges().size() == 1u);
219 BOOST_TEST(rs1.front().begin() == 1u);
220 BOOST_TEST(rs1.front().end() == 11u);
228 rs1.emplace_range(1, 4, 8);
239 BOOST_CHECK_EXCEPTION(
250 rs1.emplace_range(1, 4, 8);
263 std::vector<EventRange>
const ref_ranges{
268 BOOST_TEST(rs1 == ref);
277 auto const ref = rs1;
286 BOOST_TEST(rs1 == ref);
292 auto rs1 = RangeSet::forRun(
RunID{2});
293 auto const ref = rs1;
302 BOOST_TEST(rs1 == ref);
310 rs1.emplace_range(1, 2, 2);
311 rs1.emplace_range(1, 2, 2);
315 BOOST_TEST(rs1 == rs2);
319 BOOST_TEST(rs1 == rs2);
326 rs1.emplace_range(1, 4, 8);
327 rs1.emplace_range(2, 3, 17);
332 rs2.emplace_range(2, 7, 9);
341 auto const rs1 = RangeSet::invalid();
342 auto const rs2 = RangeSet::invalid();
348 BOOST_AUTO_TEST_SUITE_END()
EventRange full_run_event_range()
void assign_ranges(RangeSet const &rs, std::size_t const b, std::size_t const e)
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
BOOST_AUTO_TEST_CASE(empty1)
std::enable_if_t< detail::are_handles< T, U >::value, bool > disjoint_ranges(T const &a, U const &b)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::enable_if_t< detail::are_handles< T, U >::value, bool > overlapping_ranges(T const &a, U const &b)
std::enable_if_t< detail::are_handles< T, U >::value, bool > same_ranges(T const &a, U const &b)
void emplace_range(ARGS &&...)