[easytag] Add a test for et_file_tag_copy_other_into()
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Add a test for et_file_tag_copy_other_into()
- Date: Sun, 22 Feb 2015 15:27:33 +0000 (UTC)
commit 9ae72de9596dbe5715a949912fed73b1d626d80a
Author: David King <amigadave amigadave com>
Date: Sun Feb 22 13:29:58 2015 +0000
Add a test for et_file_tag_copy_other_into()
src/file_tag.c | 3 ++-
tests/test-file_tag.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/src/file_tag.c b/src/file_tag.c
index 0324279..a3595ca 100644
--- a/src/file_tag.c
+++ b/src/file_tag.c
@@ -41,6 +41,7 @@ static void
et_file_tag_free_other_field (File_Tag *file_tag)
{
g_list_free_full (file_tag->other, g_free);
+ file_tag->other = NULL;
}
@@ -75,7 +76,7 @@ et_file_tag_free (File_Tag *FileTag)
}
/*
- * Duplicate the 'other' list
+ * Duplicate the 'other' list, preserving the list already in @destination.
*/
void
et_file_tag_copy_other_into (File_Tag *destination,
diff --git a/tests/test-file_tag.c b/tests/test-file_tag.c
index 2efa5bf..52c9934 100644
--- a/tests/test-file_tag.c
+++ b/tests/test-file_tag.c
@@ -69,6 +69,37 @@ file_tag_copy (void)
}
static void
+file_tag_copy_other (void)
+{
+ File_Tag *tag1;
+ File_Tag *tag2;
+ GList *l;
+
+ tag1 = et_file_tag_new ();
+
+ g_assert (tag1);
+
+ tag1->other = g_list_prepend (tag1->other, g_strdup ("foo"));
+
+ tag2 = et_file_tag_new ();
+
+ g_assert (tag2);
+
+ tag2->other = g_list_prepend (tag2->other, g_strdup ("bar"));
+
+ et_file_tag_copy_other_into (tag1, tag2);
+
+ l = tag1->other;
+ g_assert_cmpstr (l->data, ==, "foo");
+
+ l = g_list_next (l);
+ g_assert_cmpstr (l->data, ==, "bar");
+
+ et_file_tag_free (tag2);
+ et_file_tag_free (tag1);
+}
+
+static void
file_tag_difference (void)
{
File_Tag *tag1;
@@ -116,6 +147,7 @@ main (int argc, char** argv)
g_test_add_func ("/file_tag/new", file_tag_new);
g_test_add_func ("/file_tag/copy", file_tag_copy);
+ g_test_add_func ("/file_tag/copy-other", file_tag_copy_other);
g_test_add_func ("/file_tag/difference", file_tag_difference);
return g_test_run ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]