Skip to content

Commit

Permalink
unit-testing: free allocated address memory
Browse files Browse the repository at this point in the history
  • Loading branch information
zinccyy committed Jan 9, 2023
1 parent a877356 commit 72af408
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/interfaces/tests/interfaces_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ static void test_interface_ipv4_address_set_ip_correct(void** state)

interfaces_interface_ipv4_address_element_set_ip(&address, ip);
assert_string_equal(address->address.ip, ip);

interfaces_interface_ipv4_address_element_free(&address);
assert_null(address);
}

static void test_interface_ipv4_address_set_prefix_length_correct(void** state)
Expand All @@ -485,6 +488,9 @@ static void test_interface_ipv4_address_set_prefix_length_correct(void** state)
interfaces_interface_ipv4_address_element_set_prefix_length(&address, prefix_length);
assert_int_equal(address->address.subnet.prefix_length, prefix_length);
assert_int_equal(address->address.subnet_type, interfaces_interface_ipv4_address_subnet_prefix_length);

interfaces_interface_ipv4_address_element_free(&address);
assert_null(address);
}

static void test_interface_ipv4_address_set_netmask_correct(void** state)
Expand All @@ -505,6 +511,9 @@ static void test_interface_ipv4_address_set_netmask_correct(void** state)
assert_int_equal(rc, 0);
assert_string_equal(address->address.subnet.netmask, netmask);
assert_int_equal(address->address.subnet_type, interfaces_interface_ipv4_address_subnet_netmask);

interfaces_interface_ipv4_address_element_free(&address);
assert_null(address);
}

static void test_interface_list_new_ipv6_address_correct(void** state)
Expand All @@ -515,6 +524,9 @@ static void test_interface_list_new_ipv6_address_correct(void** state)

address = interfaces_interface_ipv6_address_new();
assert_null(address);

interfaces_interface_ipv6_address_element_free(&address);
assert_null(address);
}

static void test_interface_list_new_ipv6_neighbor_correct(void** state)
Expand Down Expand Up @@ -574,6 +586,9 @@ static void test_interface_ipv6_address_set_ip_correct(void** state)

interfaces_interface_ipv6_address_element_set_ip(&address, ip);
assert_string_equal(address->address.ip, ip);

interfaces_interface_ipv6_address_element_free(&address);
assert_null(address);
}

static void test_interface_ipv6_address_set_prefix_length_correct(void** state)
Expand All @@ -591,4 +606,7 @@ static void test_interface_ipv6_address_set_prefix_length_correct(void** state)

interfaces_interface_ipv6_address_element_set_prefix_length(&address, prefix_length);
assert_int_equal(address->address.prefix_length, prefix_length);

interfaces_interface_ipv6_address_element_free(&address);
assert_null(address);
}

0 comments on commit 72af408

Please sign in to comment.