1#include <xrpl/basics/RangeSet.h>
3#include <doctest/doctest.h>
10TEST_SUITE_BEGIN(
"RangeSet");
12TEST_CASE(
"prevMissing")
22 set.insert(
range(10 * i, 10 * i + 5));
32 expected = ((i % 10) > 6) ? (i - 1) : oneBelowRange;
56TEST_CASE(
"fromString")
61 CHECK(boost::icl::length(set) == 0);
64 CHECK(boost::icl::length(set) == 0);
67 CHECK(boost::icl::length(set) == 0);
70 CHECK(boost::icl::length(set) == 0);
73 CHECK(boost::icl::length(set) == 0);
76 CHECK(boost::icl::length(set) == 1);
77 CHECK(boost::icl::first(set) == 1);
80 CHECK(boost::icl::length(set) == 1);
81 CHECK(boost::icl::first(set) == 1);
84 CHECK(boost::icl::length(set) == 1);
85 CHECK(boost::icl::first(set) == 1);
88 CHECK(boost::icl::length(set) == 4);
89 CHECK(boost::icl::first(set) == 1);
90 CHECK(!boost::icl::contains(set, 2));
91 CHECK(!boost::icl::contains(set, 3));
92 CHECK(boost::icl::contains(set, 4));
93 CHECK(boost::icl::contains(set, 5));
94 CHECK(boost::icl::last(set) == 6);
97 CHECK(boost::icl::length(set) == 5);
98 CHECK(boost::icl::first(set) == 1);
99 CHECK(boost::icl::contains(set, 2));
100 CHECK(boost::icl::contains(set, 4));
101 CHECK(boost::icl::last(set) == 6);
104 CHECK(boost::icl::length(set) == 3);
105 CHECK(boost::icl::first(set) == 1);
106 CHECK(boost::icl::contains(set, 2));
107 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.