mirror of
https://github.com/Dasharo/zephyr.git
synced 2026-03-06 14:57:20 -08:00
tests: posix: net: tests for inet_ntoa()
Add tests for inet_ntoa() Signed-off-by: Chris Friedt <chrisfriedt@gmail.com>
This commit is contained in:
24
tests/posix/net/src/inet_ntoa.c
Normal file
24
tests/posix/net/src/inet_ntoa.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2024, Friedt Professional Engineering Services, Inc
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/posix/arpa/inet.h>
|
||||
#include <zephyr/posix/netinet/in.h>
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
ZTEST(net, test_inet_ntoa)
|
||||
{
|
||||
struct in_addr in;
|
||||
|
||||
in.s_addr = htonl(0x7f000001);
|
||||
zassert_mem_equal(inet_ntoa(in), "127.0.0.1", strlen("127.0.0.1") + 1);
|
||||
|
||||
in.s_addr = htonl(0);
|
||||
zassert_mem_equal(inet_ntoa(in), "0.0.0.0", strlen("0.0.0.0") + 1);
|
||||
|
||||
in.s_addr = htonl(0xffffffff);
|
||||
zassert_mem_equal(inet_ntoa(in), "255.255.255.255", strlen("255.255.255.255") + 1);
|
||||
}
|
||||
Reference in New Issue
Block a user