11 #define BOOST_TEST_MODULE IntegerRanges
12 #include <boost/test/unit_test.hpp>
24 #include <type_traits>
28 template <
typename Cont>
29 std::size_t
count(Cont
const& cont)
38 BOOST_CHECK(ranges.
empty());
39 BOOST_CHECK_EQUAL(ranges.
size(), 0U);
40 BOOST_CHECK_EQUAL(ranges.
nRanges(), 0U);
51 BOOST_CHECK(ranges.
empty());
52 BOOST_CHECK_EQUAL(ranges.
size(), 0U);
53 BOOST_CHECK_EQUAL(ranges.
nRanges(), 0U);
57 BOOST_CHECK(ranges.
empty());
58 BOOST_CHECK_EQUAL(ranges.
size(), 0U);
59 BOOST_CHECK_EQUAL(ranges.
nRanges(), 0U);
70 std::array<std::pair<int, int>, 3U>
const groups = {
78 std::cout <<
"Testing: " << ranges << std::endl;
80 BOOST_CHECK_EQUAL(ranges.empty(),
test.empty());
81 BOOST_CHECK_EQUAL(ranges.size(),
test.size());
82 BOOST_CHECK_EQUAL(ranges.nRanges(), groups.size());
84 auto const& rangeContent = ranges.ranges();
86 BOOST_TEST_MESSAGE(
"[" << i <<
"]");
87 BOOST_CHECK_EQUAL(
r.lower,
e.first);
88 BOOST_CHECK_EQUAL(
r.upper,
e.second);
99 std::array<std::pair<int, int>, 3U>
const groups = {
107 static_assert(std::is_same_v<
108 std::remove_reference_t<decltype(ranges)>,
111 std::cout <<
"Testing: " << ranges << std::endl;
113 BOOST_CHECK_EQUAL(ranges.empty(),
test.empty());
114 BOOST_CHECK_EQUAL(ranges.size(),
test.size());
115 BOOST_CHECK_EQUAL(ranges.nRanges(), groups.size());
117 auto const& rangeContent = ranges.ranges();
119 BOOST_TEST_MESSAGE(
"[" << i <<
"]");
120 BOOST_CHECK_EQUAL(
r.lower,
e.first);
121 BOOST_CHECK_EQUAL(
r.upper,
e.second);
132 std::array<std::pair<int, int>, 3U>
const groups = {
140 std::cout <<
"Testing: " << ranges << std::endl;
142 BOOST_CHECK_EQUAL(ranges.empty(),
test.empty());
143 BOOST_CHECK_EQUAL(ranges.size(),
test.size());
144 BOOST_CHECK_EQUAL(ranges.nRanges(), groups.size());
146 auto const& rangeContent = ranges.ranges();
148 BOOST_TEST_MESSAGE(
"[" << i <<
"]");
149 BOOST_CHECK_EQUAL(
r.lower,
e.first);
150 BOOST_CHECK_EQUAL(
r.upper,
e.second);
161 std::array<std::pair<int, int>, 4U>
const groups = {
170 std::cout <<
"Testing: " << ranges << std::endl;
172 BOOST_CHECK_EQUAL(ranges.empty(),
test.empty());
173 BOOST_CHECK_EQUAL(ranges.size(),
test.size());
174 BOOST_CHECK_EQUAL(ranges.nRanges(), groups.size());
176 auto const& rangeContent = ranges.ranges();
178 BOOST_TEST_MESSAGE(
"[" << i <<
"]");
179 BOOST_CHECK_EQUAL(
r.lower,
e.first);
180 BOOST_CHECK_EQUAL(
r.upper,
e.second);
190 std::array<std::pair<int, int>, 4U>
const groups = {
199 std::cout <<
"Testing: " << ranges << std::endl;
201 BOOST_CHECK_EQUAL(ranges.empty(),
test.empty());
202 BOOST_CHECK_EQUAL(ranges.size(),
test.size() - 4U);
203 BOOST_CHECK_EQUAL(ranges.nRanges(), groups.size());
205 auto const& rangeContent = ranges.ranges();
207 BOOST_TEST_MESSAGE(
"[" << i <<
"]");
208 BOOST_CHECK_EQUAL(
r.lower,
e.first);
209 BOOST_CHECK_EQUAL(
r.upper,
e.second);
226 BOOST_CHECK_NO_THROW(
251 std::cout <<
"Ranges: " << ranges << std::endl;
254 std::stringstream sstr;
255 sstr <<
"Ranges: " << ranges;
256 BOOST_CHECK_EQUAL(sstr.str(),
"Ranges: 1 2 4--6 8 10");
void TestDefaultConstructed()
std::size_t nRanges() const noexcept
Returns the number of non-contiguous ranges in the set.
Class compacting a list of integers.
void TestIntegerRangesDocumentation()
Definition of util::enumerate().
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
IntegerRanges< typename Coll::value_type, CheckGrowing > makeIntegerRanges(Coll const &coll)
void clear() noexcept
Removes all the entries and makes the set as default-constructed.
void TestInitializerList()
then echo ***************************************echo array
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
auto end(FixedBins< T, C > const &) noexcept
std::size_t size() const noexcept
Returns the number of elements in the ranges (gaps excluded).
auto begin(FixedBins< T, C > const &) noexcept
void TestConstDefaultConstructed()
bool empty() const noexcept
Returns whether there is any element in the range set.
A sequence of contiguous ranges of integral numbers.
BEGIN_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree showermakertwo END_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree sequence::inline_paths sequence::inline_paths sequence::inline_paths showermakers test
std::size_t count(Cont const &cont)
decltype(auto) ranges() const noexcept
Returns an iterable object with all sorted ranges as elements.
BEGIN_PROLOG could also be cout