25 boost::system::error_code ec;
26 Address const result{boost::asio::ip::make_address(s, ec)};
27 if (!BEAST_EXPECTS(!ec, ec.message()))
29 if (!BEAST_EXPECTS(result.is_v4(), s +
" not v4"))
31 if (!BEAST_EXPECTS(result.to_v4().to_uint() == value, s +
" value mismatch"))
33 BEAST_EXPECTS(result.to_string() == (normal.empty() ? s : normal), s +
" as string");
113 AddressV4::bytes_type d1 = {{10, 0, 0, 1}};
115 BEAST_EXPECT(v4.to_bytes()[0] == 10);
116 BEAST_EXPECT(v4.to_bytes()[1] == 0);
117 BEAST_EXPECT(v4.to_bytes()[2] == 0);
118 BEAST_EXPECT(v4.to_bytes()[3] == 1);
120 BEAST_EXPECT((~((0xff) << 16)) == 0xff00ffff);
122 auto d2 = v4.to_bytes();
125 BEAST_EXPECT(v4.to_bytes()[0] == 10);
126 BEAST_EXPECT(v4.to_bytes()[1] == 10);
127 BEAST_EXPECT(v4.to_bytes()[2] == 0);
128 BEAST_EXPECT(v4.to_bytes()[3] == 1);
212 shouldParseEPV6(
"2001:db8:a0b:12f0::1", {{32, 01, 13, 184, 10, 11, 18, 240, 0, 0, 0, 0, 0, 0, 0, 1}}, 0);
213 shouldParseEPV6(
"[2001:db8:a0b:12f0::1]:8", {{32, 01, 13, 184, 10, 11, 18, 240, 0, 0, 0, 0, 0, 0, 0, 1}}, 8);
215 "[2001:2002:2003:2004:2005:2006:2007:2008]:65535",
216 {{32, 1, 32, 2, 32, 3, 32, 4, 32, 5, 32, 6, 32, 7, 32, 8}},
219 "2001:2002:2003:2004:2005:2006:2007:2008 65535",
220 {{32, 1, 32, 2, 32, 3, 32, 4, 32, 5, 32, 6, 32, 7, 32, 8}},
222 "[2001:2002:2003:2004:2005:2006:2007:2008]:65535");
226 AddressV4::bytes_type d = {{127, 0, 0, 1}};
233 BEAST_EXPECT(
to_string(ep) ==
"127.0.0.1:80");
235 ep =
Endpoint(boost::asio::ip::make_address_v6(boost::asio::ip::v4_mapped,
AddressV4{d}), 80);
245 BEAST_EXPECT(
get_class(ep.to_v4()) ==
'A');
251 BEAST_EXPECT(
to_string(ep) ==
"10.0.0.1");
253 ep =
Endpoint(boost::asio::ip::make_address_v6(boost::asio::ip::v4_mapped,
AddressV4{d}));
254 BEAST_EXPECT(
get_class(boost::asio::ip::make_address_v4(boost::asio::ip::v4_mapped, ep.to_v6())) ==
'A');
262 d = {{166, 78, 151, 147}};
269 BEAST_EXPECT(
to_string(ep) ==
"166.78.151.147");
271 ep =
Endpoint(boost::asio::ip::make_address_v6(boost::asio::ip::v4_mapped,
AddressV4{d}));
280 AddressV6::bytes_type d2 = {{253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}};
296 BEAST_EXPECT(ep.address() == ep1.address());
297 BEAST_EXPECT(ep1.port() == 2016);
301 BEAST_EXPECT(ep.address() == ep2.address());
302 BEAST_EXPECT(ep2.port() == 2016);
303 BEAST_EXPECT(ep1 == ep2);
307 BEAST_EXPECT(ep.address() == ep3.address());
308 BEAST_EXPECT(ep3.port() == 2016);
309 BEAST_EXPECT(ep2 == ep3);
313 BEAST_EXPECT(ep.address() == ep4.address());
314 BEAST_EXPECT(ep4.port() == 2016);
315 BEAST_EXPECT(ep3 == ep4);
325 BEAST_EXPECT(ep.port() == 2017);
326 BEAST_EXPECT(ep.address() ==
AddressV6{});
351 failParseEP(
"[1234:5678:90ab:cdef:1234:5678:90ab:cdef:1111]:1");
352 failParseEP(
"[1234:5678:90ab:cdef:1234:5678:90ab:cdef:1111]:12345");
359 constexpr auto items{100};
361 for (
auto i = 0; i < items; ++i)
367 BEAST_EXPECT(max_lf > 0.90);