Skip to content

Commit 9283800

Browse files
committed
Add unit test to check that socket::bind(0) binds to a valid port
1 parent 055a1bd commit 9283800

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

testing/test_int_network.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,10 @@ TEST_CASE("reuseport", "[network][basic][!mayfail]") {
230230
io_ctx.run();
231231
}
232232
}
233+
234+
TEST_CASE("bindzero", "[network][basic]") {
235+
asio::io_context ctx;
236+
asio::ip::udp::socket sock(ctx, asio::ip::udp::v4());
237+
sock.bind(asio::ip::udp::endpoint(asio::ip::address_v4::any(), 0));
238+
REQUIRE(sock.local_endpoint().port() != 0);
239+
}

0 commit comments

Comments
 (0)