1#include <xrpl/basics/RangeSet.h>
3#include <boost/icl/concept/interval_associator.hpp>
4#include <boost/icl/concept/interval_set.hpp>
6#include <gtest/gtest.h>
23 set.insert(
range(10 * i, (10 * i) + 5));
33 expected = ((i % 10) > 6) ? (i - 1) : oneBelowRange;
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), 0);
77 EXPECT_EQ(boost::icl::length(
set), 1);
78 EXPECT_EQ(boost::icl::first(
set), 1);
81 EXPECT_EQ(boost::icl::length(
set), 1);
82 EXPECT_EQ(boost::icl::first(
set), 1);
85 EXPECT_EQ(boost::icl::length(
set), 1);
86 EXPECT_EQ(boost::icl::first(
set), 1);
89 EXPECT_EQ(boost::icl::length(
set), 4);
90 EXPECT_EQ(boost::icl::first(
set), 1);
91 EXPECT_FALSE(boost::icl::contains(
set, 2));
92 EXPECT_FALSE(boost::icl::contains(
set, 3));
93 EXPECT_TRUE(boost::icl::contains(
set, 4));
94 EXPECT_TRUE(boost::icl::contains(
set, 5));
95 EXPECT_EQ(boost::icl::last(
set), 6);
98 EXPECT_EQ(boost::icl::length(
set), 5);
99 EXPECT_EQ(boost::icl::first(
set), 1);
100 EXPECT_TRUE(boost::icl::contains(
set, 2));
101 EXPECT_TRUE(boost::icl::contains(
set, 4));
102 EXPECT_EQ(boost::icl::last(
set), 6);
105 EXPECT_EQ(boost::icl::length(
set), 3);
106 EXPECT_EQ(boost::icl::first(
set), 1);
107 EXPECT_TRUE(boost::icl::contains(
set, 2));
108 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.
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
std::string to_string(BaseUInt< Bits, Tag > const &a)
bool fromString(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.