1#include <xrpl/basics/RangeSet.h>
3#include <gtest/gtest.h>
20 set.insert(
range(10 * i, 10 * i + 5));
30 expected = ((i % 10) > 6) ? (i - 1) : oneBelowRange;
59 EXPECT_EQ(boost::icl::length(set), 0);
62 EXPECT_EQ(boost::icl::length(set), 0);
65 EXPECT_EQ(boost::icl::length(set), 0);
68 EXPECT_EQ(boost::icl::length(set), 0);
71 EXPECT_EQ(boost::icl::length(set), 0);
74 EXPECT_EQ(boost::icl::length(set), 1);
75 EXPECT_EQ(boost::icl::first(set), 1);
78 EXPECT_EQ(boost::icl::length(set), 1);
79 EXPECT_EQ(boost::icl::first(set), 1);
82 EXPECT_EQ(boost::icl::length(set), 1);
83 EXPECT_EQ(boost::icl::first(set), 1);
86 EXPECT_EQ(boost::icl::length(set), 4);
87 EXPECT_EQ(boost::icl::first(set), 1);
88 EXPECT_FALSE(boost::icl::contains(set, 2));
89 EXPECT_FALSE(boost::icl::contains(set, 3));
90 EXPECT_TRUE(boost::icl::contains(set, 4));
91 EXPECT_TRUE(boost::icl::contains(set, 5));
92 EXPECT_EQ(boost::icl::last(set), 6);
95 EXPECT_EQ(boost::icl::length(set), 5);
96 EXPECT_EQ(boost::icl::first(set), 1);
97 EXPECT_TRUE(boost::icl::contains(set, 2));
98 EXPECT_TRUE(boost::icl::contains(set, 4));
99 EXPECT_EQ(boost::icl::last(set), 6);
102 EXPECT_EQ(boost::icl::length(set), 3);
103 EXPECT_EQ(boost::icl::first(set), 1);
104 EXPECT_TRUE(boost::icl::contains(set, 2));
105 EXPECT_EQ(boost::icl::last(set), 6);
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
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,...
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 from_string(RangeSet< T > &rs, std::string const &s)
Convert the given styled string to a RangeSet.
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
std::string to_string(base_uint< Bits, Tag > const &a)
boost::icl::interval_set< T, std::less, ClosedInterval< T > > RangeSet
A set of closed intervals over the domain T.