20#include <xrpl/basics/RangeSet.h>
22#include <doctest/doctest.h>
29TEST_SUITE_BEGIN(
"RangeSet");
31TEST_CASE(
"prevMissing")
41 set.insert(
range(10 * i, 10 * i + 5));
51 expected = ((i % 10) > 6) ? (i - 1) : oneBelowRange;
75TEST_CASE(
"fromString")
80 CHECK(boost::icl::length(set) == 0);
83 CHECK(boost::icl::length(set) == 0);
86 CHECK(boost::icl::length(set) == 0);
89 CHECK(boost::icl::length(set) == 0);
92 CHECK(boost::icl::length(set) == 0);
95 CHECK(boost::icl::length(set) == 1);
96 CHECK(boost::icl::first(set) == 1);
99 CHECK(boost::icl::length(set) == 1);
100 CHECK(boost::icl::first(set) == 1);
103 CHECK(boost::icl::length(set) == 1);
104 CHECK(boost::icl::first(set) == 1);
107 CHECK(boost::icl::length(set) == 4);
108 CHECK(boost::icl::first(set) == 1);
109 CHECK(!boost::icl::contains(set, 2));
110 CHECK(!boost::icl::contains(set, 3));
111 CHECK(boost::icl::contains(set, 4));
112 CHECK(boost::icl::contains(set, 5));
113 CHECK(boost::icl::last(set) == 6);
116 CHECK(boost::icl::length(set) == 5);
117 CHECK(boost::icl::first(set) == 1);
118 CHECK(boost::icl::contains(set, 2));
119 CHECK(boost::icl::contains(set, 4));
120 CHECK(boost::icl::last(set) == 6);
123 CHECK(boost::icl::length(set) == 3);
124 CHECK(boost::icl::first(set) == 1);
125 CHECK(boost::icl::contains(set, 2));
126 CHECK(boost::icl::last(set) == 6);
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::optional< T > prevMissing(RangeSet< T > const &rs, T t, T minVal=0)
Find the largest value not in the set that is less than a given value.
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
bool from_string(RangeSet< T > &rs, std::string const &s)
Convert the given styled string to a RangeSet.
boost::icl::interval_set< T, std::less, ClosedInterval< T > > RangeSet
A set of closed intervals over the domain T.
std::string to_string(base_uint< Bits, Tag > const &a)
ClosedInterval< T > range(T low, T high)
Create a closed range interval.