mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-25 10:48:53 +00:00
Tests: Add tests for gethostbyname()
This commit is contained in:
parent
fd792f93c4
commit
db2f96e4ed
Notes:
sideshowbarker
2024-07-17 22:55:25 +09:00
Author: https://github.com/mkanilsson
Commit: db2f96e4ed
Pull-request: https://github.com/SerenityOS/serenity/pull/20536
Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 17 additions and 0 deletions
|
@ -9,6 +9,23 @@
|
|||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
|
||||
TEST_CASE(gethostbyname_should_return_host_not_found)
|
||||
{
|
||||
auto* res = gethostbyname("unknownhostthatdoesntexistandhopefullyneverwill.com");
|
||||
EXPECT_EQ(res, nullptr);
|
||||
EXPECT_EQ(h_errno, HOST_NOT_FOUND);
|
||||
}
|
||||
|
||||
TEST_CASE(gethostbyname)
|
||||
{
|
||||
auto* result = gethostbyname("google.com");
|
||||
EXPECT_NE(result, nullptr);
|
||||
EXPECT_EQ(h_errno, 0);
|
||||
EXPECT_EQ(result->h_aliases[0], nullptr);
|
||||
EXPECT_EQ(result->h_addr_list[1], nullptr);
|
||||
EXPECT_EQ(result->h_addrtype, AF_INET);
|
||||
}
|
||||
|
||||
TEST_CASE(gethostbyname_r_should_return_erange_when_buffer_is_to_small)
|
||||
{
|
||||
constexpr size_t buffer_size = 2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue