tests: fix memory leaks

This commit is contained in:
Yunlian Jiang
2015-03-27 20:30:18 +01:00
committed by Aleksander Morgado
parent 948be2343a
commit 977cf658a6
3 changed files with 13 additions and 5 deletions

View File

@@ -420,6 +420,7 @@ test_prefmode_response (void)
found = mm_huawei_parse_prefmode_response (prefmode_response_tests[i].str, found = mm_huawei_parse_prefmode_response (prefmode_response_tests[i].str,
combinations, combinations,
&error); &error);
g_assert_no_error (error);
g_assert (found != NULL); g_assert (found != NULL);
g_assert_cmpuint (found->allowed, ==, prefmode_response_tests[i].allowed); g_assert_cmpuint (found->allowed, ==, prefmode_response_tests[i].allowed);
g_assert_cmpuint (found->preferred, ==, prefmode_response_tests[i].preferred); g_assert_cmpuint (found->preferred, ==, prefmode_response_tests[i].preferred);
@@ -672,6 +673,7 @@ test_syscfg_response (void)
combinations, combinations,
&error); &error);
g_assert_no_error (error);
g_assert (found != NULL); g_assert (found != NULL);
g_assert_cmpuint (found->allowed, ==, syscfg_response_tests[i].allowed); g_assert_cmpuint (found->allowed, ==, syscfg_response_tests[i].allowed);
g_assert_cmpuint (found->preferred, ==, syscfg_response_tests[i].preferred); g_assert_cmpuint (found->preferred, ==, syscfg_response_tests[i].preferred);
@@ -993,6 +995,7 @@ test_syscfgex_response (void)
combinations, combinations,
&error); &error);
g_assert_no_error (error);
g_assert (found != NULL); g_assert (found != NULL);
g_assert_cmpuint (found->allowed, ==, syscfgex_response_tests[i].allowed); g_assert_cmpuint (found->allowed, ==, syscfgex_response_tests[i].allowed);
g_assert_cmpuint (found->preferred, ==, syscfgex_response_tests[i].preferred); g_assert_cmpuint (found->preferred, ==, syscfgex_response_tests[i].preferred);
@@ -1085,8 +1088,10 @@ test_nwtime (void)
g_assert (nwtime_tests[i].leap_seconds == mm_network_timezone_get_leap_seconds (tz)); g_assert (nwtime_tests[i].leap_seconds == mm_network_timezone_get_leap_seconds (tz));
} }
if (iso8601) g_free (iso8601);
g_free (iso8601);
if (tz)
g_object_unref (tz);
} }
} }
@@ -1125,11 +1130,10 @@ test_time (void)
g_assert (ret == time_tests[i].ret); g_assert (ret == time_tests[i].ret);
g_assert (ret == (error ? FALSE : TRUE)); g_assert (ret == (error ? FALSE : TRUE));
g_clear_error (&error);
g_assert_cmpstr (time_tests[i].iso8601, ==, iso8601); g_assert_cmpstr (time_tests[i].iso8601, ==, iso8601);
g_free (iso8601);
if (iso8601)
g_free (iso8601);
} }
} }

View File

@@ -141,6 +141,7 @@ test_ipdpaddr (void)
g_assert_cmpint (dnslen, ==, 1); g_assert_cmpint (dnslen, ==, 1);
g_assert_cmpstr (dns[0], ==, ipdpaddr_tests[i].ipv4_dns1); g_assert_cmpstr (dns[0], ==, ipdpaddr_tests[i].ipv4_dns1);
g_assert_cmpstr (dns[1], ==, ipdpaddr_tests[i].ipv4_dns2); g_assert_cmpstr (dns[1], ==, ipdpaddr_tests[i].ipv4_dns2);
g_object_unref (ipv4);
} else } else
g_assert (ipv4 == NULL); g_assert (ipv4 == NULL);
@@ -166,6 +167,7 @@ test_ipdpaddr (void)
dnslen = g_strv_length ((gchar **) dns); dnslen = g_strv_length ((gchar **) dns);
g_assert_cmpint (dnslen, ==, 1); g_assert_cmpint (dnslen, ==, 1);
g_assert_cmpstr (dns[0], ==, ipdpaddr_tests[i].ipv6_dns1); g_assert_cmpstr (dns[0], ==, ipdpaddr_tests[i].ipv6_dns1);
g_object_unref (ipv6);
} else } else
g_assert (ipv6 == NULL); g_assert (ipv6 == NULL);
} }

View File

@@ -96,6 +96,7 @@ test_e2ipcfg (void)
g_assert_cmpint (dnslen, ==, 1); g_assert_cmpint (dnslen, ==, 1);
g_assert_cmpstr (dns[0], ==, tests[i].ipv4_dns1); g_assert_cmpstr (dns[0], ==, tests[i].ipv4_dns1);
g_assert_cmpstr (dns[1], ==, tests[i].ipv4_dns2); g_assert_cmpstr (dns[1], ==, tests[i].ipv4_dns2);
g_object_unref (ipv4);
} else } else
g_assert (ipv4 == NULL); g_assert (ipv4 == NULL);
@@ -122,6 +123,7 @@ test_e2ipcfg (void)
g_assert_cmpint (dnslen, ==, 1); g_assert_cmpint (dnslen, ==, 1);
g_assert_cmpstr (dns[0], ==, tests[i].ipv6_dns1); g_assert_cmpstr (dns[0], ==, tests[i].ipv6_dns1);
g_assert_cmpstr (dns[1], ==, tests[i].ipv6_dns2); g_assert_cmpstr (dns[1], ==, tests[i].ipv6_dns2);
g_object_unref (ipv6);
} else } else
g_assert (ipv6 == NULL); g_assert (ipv6 == NULL);
} }