31 std::set<IP::Route> routes;
32 routes.emplace(
"1.2.3.4/24");
33 routes.emplace(
"1.2.3.0/24");
34 routes.emplace(
"1.2.3.2/24");
35 routes.emplace(
"1.2.3.1/24");
36 routes.emplace(
"128.0.0.0/1");
37 routes.emplace(
"1:2:3:4:5:6:dead:beef/64");
38 routes.emplace(
"1:2:3:4:5:6:dead:bead/64");
40 std::stringstream
out;
41 for (
const auto &r : routes)
42 out << r.to_string() << std::endl;
44 ASSERT_EQ(
"128.0.0.0/1\n"
49 "1:2:3:4:5:6:dead:bead/64\n"
50 "1:2:3:4:5:6:dead:beef/64\n",
54template <
typename LIST>
57 typedef typename LIST::value_type RT;
58 std::stringstream
out;
59 for (
const auto &r : rtlist)
62 if (r.is_canonical() && r.split(r1, r2))
64 out << r <<
' ' << r1 <<
' ' << r2 << std::endl;
73 routes.emplace_back(
"1.2.3.4/24");
74 routes.emplace_back(
"1.2.3.0/24");
75 routes.emplace_back(
"1.2.3.2/24");
76 routes.emplace_back(
"1.2.3.1/24");
77 routes.emplace_back(
"128.0.0.0/1");
82 test_split(routes,
"1.2.3.0/24 1.2.3.0/25 1.2.3.128/25\n128.0.0.0/1 128.0.0.0/2 192.0.0.0/2\n");
88 routes.emplace_back(
"1:2:3:4:5:6:dead:beef/64");
89 routes.emplace_back(
"cafe:babe::/64");
93 test_split(routes,
"cafe:babe::/64 cafe:babe::/65 cafe:babe:0:0:8000::/65\n");
99 routes.emplace_back(
"1.2.3.4/24");
100 routes.emplace_back(
"1.2.3.0/24");
101 routes.emplace_back(
"1.2.3.2/24");
102 routes.emplace_back(
"1.2.3.1/24");
103 routes.emplace_back(
"128.0.0.0/1");
104 routes.emplace_back(
"1:2:3:4:5:6:dead:beef/64");
105 routes.emplace_back(
"cafe:babe::/64");
112 test_split(routes,
"1.2.3.0/24 1.2.3.0/25 1.2.3.128/25\n"
113 "128.0.0.0/1 128.0.0.0/2 192.0.0.0/2\n"
114 "cafe:babe::/64 cafe:babe::/65 cafe:babe:0:0:8000::/65\n");
121 test_route_parse(
"fe80::6470:7dff:fea5:f360/64",
"fe80::6470:7dff:fea5:f360/64",
true);
static Addr from_string(const std::string &ipstr, const TITLE &title, const Version required_version)
std::string to_string() const
static Addr from_string(const std::string &ipstr, const TITLE &title)
static Addr from_string(const std::string &ipstr, const TITLE &title)
bool contains(const R &c) const
static std::stringstream out
void test_route_parse(const std::string &rstr, const std::string &expected, bool ipv6)
void test_split(const LIST &rtlist, const std::string &expected)