35 boost::system::error_code ec;
36 Address const result{boost::asio::ip::make_address(s, ec)};
37 if (!BEAST_EXPECTS(!ec, ec.message()))
39 if (!BEAST_EXPECTS(result.is_v4(), s +
" not v4"))
41 if (!BEAST_EXPECTS(result.to_v4().to_uint() == value, s +
" value mismatch"))
43 BEAST_EXPECTS(result.to_string() == (normal.empty() ? s : normal), s +
" as string");
123 AddressV4::bytes_type
const d1 = {{10, 0, 0, 1}};
125 BEAST_EXPECT(v4.to_bytes()[0] == 10);
126 BEAST_EXPECT(v4.to_bytes()[1] == 0);
127 BEAST_EXPECT(v4.to_bytes()[2] == 0);
128 BEAST_EXPECT(v4.to_bytes()[3] == 1);
130 BEAST_EXPECT((~((0xff) << 16)) == 0xff00ffff);
132 auto d2 = v4.to_bytes();
135 BEAST_EXPECT(v4.to_bytes()[0] == 10);
136 BEAST_EXPECT(v4.to_bytes()[1] == 10);
137 BEAST_EXPECT(v4.to_bytes()[2] == 0);
138 BEAST_EXPECT(v4.to_bytes()[3] == 1);
223 "2001:db8:a0b:12f0::1",
224 {{32, 01, 13, 184, 10, 11, 18, 240, 0, 0, 0, 0, 0, 0, 0, 1}},
227 "[2001:db8:a0b:12f0::1]:8",
228 {{32, 01, 13, 184, 10, 11, 18, 240, 0, 0, 0, 0, 0, 0, 0, 1}},
231 "[2001:2002:2003:2004:2005:2006:2007:2008]:65535",
232 {{32, 1, 32, 2, 32, 3, 32, 4, 32, 5, 32, 6, 32, 7, 32, 8}},
235 "2001:2002:2003:2004:2005:2006:2007:2008 65535",
236 {{32, 1, 32, 2, 32, 3, 32, 4, 32, 5, 32, 6, 32, 7, 32, 8}},
238 "[2001:2002:2003:2004:2005:2006:2007:2008]:65535");
242 AddressV4::bytes_type d = {{127, 0, 0, 1}};
249 BEAST_EXPECT(
to_string(ep) ==
"127.0.0.1:80");
252 boost::asio::ip::make_address_v6(boost::asio::ip::v4_mapped,
AddressV4{d}), 80);
262 BEAST_EXPECT(
getClass(ep.toV4()) ==
'A');
268 BEAST_EXPECT(
to_string(ep) ==
"10.0.0.1");
270 ep =
Endpoint(boost::asio::ip::make_address_v6(boost::asio::ip::v4_mapped,
AddressV4{d}));
272 getClass(boost::asio::ip::make_address_v4(boost::asio::ip::v4_mapped, ep.toV6())) ==
281 d = {{166, 78, 151, 147}};
288 BEAST_EXPECT(
to_string(ep) ==
"166.78.151.147");
290 ep =
Endpoint(boost::asio::ip::make_address_v6(boost::asio::ip::v4_mapped,
AddressV4{d}));
299 AddressV6::bytes_type
const d2 = {{253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}};
315 BEAST_EXPECT(ep.address() == ep1.address());
316 BEAST_EXPECT(ep1.port() == 2016);
320 BEAST_EXPECT(ep.address() == ep2.address());
321 BEAST_EXPECT(ep2.port() == 2016);
322 BEAST_EXPECT(ep1 == ep2);
326 BEAST_EXPECT(ep.address() == ep3.address());
327 BEAST_EXPECT(ep3.port() == 2016);
328 BEAST_EXPECT(ep2 == ep3);
332 BEAST_EXPECT(ep.address() == ep4.address());
333 BEAST_EXPECT(ep4.port() == 2016);
334 BEAST_EXPECT(ep3 == ep4);
344 BEAST_EXPECT(ep.port() == 2017);
345 BEAST_EXPECT(ep.address() ==
AddressV6{});
370 failParseEP(
"[1234:5678:90ab:cdef:1234:5678:90ab:cdef:1111]:1");
371 failParseEP(
"[1234:5678:90ab:cdef:1234:5678:90ab:cdef:1111]:12345");
378 static constexpr auto kItems{100};
380 for (
auto i = 0; i < kItems; ++i)
386 BEAST_EXPECT(maxLf > 0.90);