Commit 6b9340eb authored by Andrea Azzarone's avatar Andrea Azzarone 🚴

tests: Fix memory leaks

Closes: #59
parent 67958708
......@@ -66,6 +66,7 @@ test_exif_parse (void)
g_assert_cmpstr (exif->gps_direction, ==, "12.3"); // -n -Exif:GPSImgDirection=12.3
tracker_exif_free (exif);
g_free (blob);
}
static void
......@@ -80,6 +81,7 @@ test_exif_parse_empty (void)
exif = tracker_exif_new ((guchar *)blob, length, "test://file");
tracker_exif_free (exif);
g_free (blob);
}
int
......
......@@ -120,6 +120,8 @@ load_iptc_blob (const gchar *filename)
marker = marker->next;
}
jpeg_destroy_decompress (&cinfo);
g_free (uri);
fclose (f);
......
......@@ -213,6 +213,7 @@ test_date_to_iso8601 ()
result = tracker_date_format_to_iso8601 ("2010:03:13 12:12:12", "%Y:%m:%d %H:%M:%S");
g_assert (g_str_has_prefix (result, "2010-03-13T12:12:12"));
g_assert_cmpint (strlen (result), <=, 25);
g_free (result);
/* Pattern and string don't match */
result = tracker_date_format_to_iso8601 ("2010:03:13 12:12", "%Y:%m:%d %H:%M:%S");
......@@ -268,12 +269,17 @@ test_getline (void)
f = fopen (TOP_SRCDIR "/tests/libtracker-extract/getline-test.txt", "r");
g_assert_cmpint (tracker_getline (&line, &n, f), >, 0);
g_assert_cmpstr (line, ==, "Line 1\n");
g_free (line);
line = NULL;
g_assert_cmpint (tracker_getline (&line, &n, f), >, 0);
g_assert_cmpstr (line, ==, "line 2\n");
g_free (line);
line = NULL;
g_assert_cmpint (tracker_getline (&line, &n, f), >, 0);
g_assert_cmpstr (line, ==, "line 3\n");
g_free (line);
}
int
......
......@@ -328,6 +328,11 @@ test_xmp_apply_location (void)
g_assert_cmpstr (tracker_resource_get_first_string (address, "nco:region"), ==, data.state);
g_assert_cmpstr (tracker_resource_get_first_string (address, "nco:locality"), ==, data.city);
g_assert_cmpstr (tracker_resource_get_first_string (address, "nco:country"), ==, data.country);
g_free (data.address);
g_free (data.city);
g_free (data.state);
g_free (data.country);
}
......
......@@ -110,6 +110,9 @@ test_string_to_date (void)
/* More cases of string->date are tested in tracker_date_time_from_string...
* it is more convinient to test them there
*/
g_date_free (result);
g_date_free (expected);
}
static void
......@@ -137,6 +140,9 @@ test_date_to_string (void)
result = tracker_date_to_string (input);
g_assert (result != NULL && strncmp (result, "2008-06-16T23:53:10Z", 19) == 0);
g_free (result);
g_free (original);
}
static void
......
......@@ -168,6 +168,7 @@ test_path_evaluate_name (void)
result = tracker_path_evaluate_name ("just-a-filename");
g_assert_cmpstr (result, ==, "just-a-filename");
g_free (result);
result = tracker_path_evaluate_name ("$HOME/all/dir/");
expected = g_build_path (G_DIR_SEPARATOR_S, home, "/all/dir", NULL);
......@@ -215,9 +216,11 @@ test_path_evaluate_name (void)
result = tracker_path_evaluate_name ("$UNDEFINED/something");
g_assert_cmpstr (result, ==, "/something");
g_free (result);
result = tracker_path_evaluate_name (tracker_test_helpers_get_nonutf8 ());
g_assert_cmpstr (result, ==, tracker_test_helpers_get_nonutf8 ());
g_free (result);
g_free (home);
g_free (pwd);
......
......@@ -58,6 +58,7 @@ test_string_in_string_list (void)
g_assert_cmpint (tracker_string_in_string_list ("Audio:Title", pieces), ==, 12);
g_assert_cmpint (tracker_string_in_string_list ("terms", NULL), ==, -1);
g_strfreev (pieces);
}
static void
......@@ -143,6 +144,7 @@ test_string_to_string_list (void)
result = tracker_string_to_string_list (input);
g_assert_cmpint (g_strv_length (result), ==, 1);
g_assert_cmpstr (result [0], ==, "first line");
g_strfreev (result);
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment