lwip/test/unit/core/test_dns.c
Erik Ekman 264a5a3e97 Rename IP and Ethernet equality checkers from _cmp to _eq
Functions ending in cmp are expected to return 0 on equality but these
return non-zero.

eth_addr_cmp -> eth_addr_eq

ip_addr_cmp -> ip_addr_eq
ip4_addr_cmp -> ip4_addr_eq
ip6_addr_cmp -> ip6_addr_eq

ip_addr_netcmp -> ip_addr_net_eq
ip4_addr_netcmp -> ip4_addr_net_eq
ip6_addr_netcmp -> ip6_addr_net_eq

ip_addr_cmp_zoneless -> ip_addr_zoneless_eq
ip6_addr_cmp_zoneless -> ip6_addr_zoneless_eq

ip6_addr_cmp_zone -> ip6_addr_zone_eq
ip6_addr_netcmp_zoneless -> ip6_addr_net_zoneless_eq
ip6_addr_nethostcmp -> ip6_addr_nethost_eq
ip6_addr_cmp_packed -> ip6_addr_packed_eq
ip6_addr_cmp_solicitednode -> ip6_addr_solicitednode_eq

All call sites have been changed, and fallback macros have been added to not
break external users.
2020-07-07 18:51:45 +02:00

52 lines
1.0 KiB
C

#include "test_dns.h"
#include "lwip/dns.h"
/* Setups/teardown functions */
static void
dns_setup(void)
{
}
static void
dns_teardown(void)
{
}
/* Test functions */
START_TEST(test_dns_set_get_server)
{
int i;
LWIP_UNUSED_ARG(_i);
for (i = 0; i < 256; i++) {
ip_addr_t server;
/* Should return a zeroed address for any index */
fail_unless(dns_getserver(i));
fail_unless(ip_addr_isany(dns_getserver(i)));
/* Should accept setting address for any index, and ignore if out of range */
IP_ADDR4(&server, 10, 0, 0, i);
dns_setserver(i, &server);
fail_unless(dns_getserver(i));
if (i < DNS_MAX_SERVERS) {
fail_unless(ip_addr_eq(dns_getserver(i), &server) == 1);
} else {
fail_unless(ip_addr_isany(dns_getserver(i)));
}
}
}
END_TEST
/** Create the suite including all tests for this module */
Suite *
dns_suite(void)
{
testfunc tests[] = {
TESTFUNC(test_dns_set_get_server)
};
return create_suite("DNS", tests, sizeof(tests)/sizeof(testfunc), dns_setup, dns_teardown);
}