20#include <xrpl/basics/RangeSet.h>
21#include <xrpl/beast/unit_test.h>
40 set.insert(
range(10 * i, 10 * i + 5));
50 expected = ((i % 10) > 6) ? (i - 1) : oneBelowRange;
85 BEAST_EXPECT(boost::icl::length(
set) == 0);
88 BEAST_EXPECT(boost::icl::length(
set) == 0);
91 BEAST_EXPECT(boost::icl::length(
set) == 0);
94 BEAST_EXPECT(boost::icl::length(
set) == 0);
97 BEAST_EXPECT(boost::icl::length(
set) == 0);
100 BEAST_EXPECT(boost::icl::length(
set) == 1);
101 BEAST_EXPECT(boost::icl::first(
set) == 1);
104 BEAST_EXPECT(boost::icl::length(
set) == 1);
105 BEAST_EXPECT(boost::icl::first(
set) == 1);
108 BEAST_EXPECT(boost::icl::length(
set) == 1);
109 BEAST_EXPECT(boost::icl::first(
set) == 1);
112 BEAST_EXPECT(boost::icl::length(
set) == 4);
113 BEAST_EXPECT(boost::icl::first(
set) == 1);
114 BEAST_EXPECT(!boost::icl::contains(
set, 2));
115 BEAST_EXPECT(!boost::icl::contains(
set, 3));
116 BEAST_EXPECT(boost::icl::contains(
set, 4));
117 BEAST_EXPECT(boost::icl::contains(
set, 5));
118 BEAST_EXPECT(boost::icl::last(
set) == 6);
121 BEAST_EXPECT(boost::icl::length(
set) == 5);
122 BEAST_EXPECT(boost::icl::first(
set) == 1);
123 BEAST_EXPECT(boost::icl::contains(
set, 2));
124 BEAST_EXPECT(boost::icl::contains(
set, 4));
125 BEAST_EXPECT(boost::icl::last(
set) == 6);
128 BEAST_EXPECT(boost::icl::length(
set) == 3);
129 BEAST_EXPECT(boost::icl::first(
set) == 1);
130 BEAST_EXPECT(boost::icl::contains(
set, 2));
131 BEAST_EXPECT(boost::icl::last(
set) == 6);
testcase_t testcase
Memberspace for declaring test cases.
void run() override
Runs the suite.
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.