mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 18:40:16 +01:00
libnm/tests: test nm_ip_addr_zero is all-zero and compares to IP addresse as expected
This commit is contained in:
parent
e49e509262
commit
299fc555b4
1 changed files with 24 additions and 0 deletions
|
|
@ -8328,6 +8328,28 @@ test_integrate_maincontext (gconstpointer test_data)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_nm_ip_addr_zero (void)
|
||||
{
|
||||
in_addr_t a4 = nmtst_inet4_from_string ("0.0.0.0");
|
||||
struct in6_addr a6 = *nmtst_inet6_from_string ("::");
|
||||
char buf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
|
||||
g_assert (IN6_IS_ADDR_UNSPECIFIED (&nm_ip_addr_zero.addr6));
|
||||
g_assert (memcmp (&nm_ip_addr_zero.addr6, &in6addr_any, sizeof (in6addr_any)) == 0);
|
||||
|
||||
g_assert (memcmp (&nm_ip_addr_zero, &a4, sizeof (a4)) == 0);
|
||||
g_assert (memcmp (&nm_ip_addr_zero, &a6, sizeof (a6)) == 0);
|
||||
|
||||
g_assert_cmpstr (nm_utils_inet4_ntop (nm_ip_addr_zero.addr4, buf), ==, "0.0.0.0");
|
||||
g_assert_cmpstr (nm_utils_inet6_ntop (&nm_ip_addr_zero.addr6, buf), ==, "::");
|
||||
|
||||
g_assert_cmpstr (nm_utils_inet_ntop (AF_INET, &nm_ip_addr_zero, buf), ==, "0.0.0.0");
|
||||
g_assert_cmpstr (nm_utils_inet_ntop (AF_INET6, &nm_ip_addr_zero, buf), ==, "::");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMTST_DEFINE ();
|
||||
|
||||
int main (int argc, char **argv)
|
||||
|
|
@ -8492,5 +8514,7 @@ int main (int argc, char **argv)
|
|||
g_test_add_data_func ("/core/general/test_integrate_maincontext/1", GUINT_TO_POINTER (1), test_integrate_maincontext);
|
||||
g_test_add_data_func ("/core/general/test_integrate_maincontext/2", GUINT_TO_POINTER (2), test_integrate_maincontext);
|
||||
|
||||
g_test_add_func ("/core/general/test_nm_ip_addr_zero", test_nm_ip_addr_zero);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue