mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
Tests: Add should_error_when_connection_fails test to TestLibCoreStream
This test makes sure that Socket classes such as TCPSocket properly return an error when connection fails rather than crashing or creating an invalid object.
This commit is contained in:
parent
ab36fb7a23
commit
c63feb4f09
1 changed files with 12 additions and 0 deletions
|
@ -140,6 +140,18 @@ TEST_CASE(file_adopt_invalid_fd)
|
|||
|
||||
// TCPSocket tests
|
||||
|
||||
TEST_CASE(should_error_when_connection_fails)
|
||||
{
|
||||
// NOTE: This is required here because Core::TCPSocket requires
|
||||
// Core::EventLoop through Core::Notifier.
|
||||
Core::EventLoop event_loop;
|
||||
|
||||
auto maybe_tcp_socket = Core::Stream::TCPSocket::connect({ { 127, 0, 0, 1 }, 1234 });
|
||||
EXPECT(maybe_tcp_socket.is_error());
|
||||
EXPECT(maybe_tcp_socket.error().is_syscall());
|
||||
EXPECT(maybe_tcp_socket.error().code() == ECONNREFUSED);
|
||||
}
|
||||
|
||||
constexpr auto sent_data = "Mr. Watson, come here. I want to see you."sv;
|
||||
|
||||
TEST_CASE(tcp_socket_read)
|
||||
|
|
Loading…
Add table
Reference in a new issue