[easytag] Add File_Tag tests



commit 8e51def2639137056a0f3ebe845986a2934143da
Author: David King <amigadave amigadave com>
Date:   Sat Feb 21 16:49:08 2015 +0000

    Add File_Tag tests

 Makefile.am           |   19 ++++++++
 tests/test-file_tag.c |  113 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 132 insertions(+), 0 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index f273db8..50e70db 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -436,6 +436,7 @@ check_PROGRAMS = \
        tests/test-dlm \
        tests/test-file_description \
        tests/test-file_info \
+       tests/test-file_tag \
        tests/test-misc \
        tests/test-picture \
        tests/test-scan
@@ -485,6 +486,24 @@ tests_test_file_info_SOURCES = \
 tests_test_file_info_LDADD = \
        $(EASYTAG_LIBS)
 
+tests_test_file_tag_CPPFLAGS = \
+       -I$(top_srcdir)/src \
+       -I$(top_srcdir)/src/tags \
+       -I$(top_builddir)
+
+tests_test_file_tag_CFLAGS = \
+       $(WARN_CFLAGS) \
+       $(EASYTAG_CFLAGS)
+
+tests_test_file_tag_SOURCES = \
+       tests/test-file_tag.c \
+       src/file_tag.c \
+       src/misc.c \
+       src/picture.c
+
+tests_test_file_tag_LDADD = \
+       $(EASYTAG_LIBS)
+
 tests_test_misc_CPPFLAGS = \
        -I$(top_srcdir)/src \
        -I$(top_srcdir)/src/tags \
diff --git a/tests/test-file_tag.c b/tests/test-file_tag.c
new file mode 100644
index 0000000..2b85b3c
--- /dev/null
+++ b/tests/test-file_tag.c
@@ -0,0 +1,113 @@
+/* EasyTAG - tag editor for audio files
+ * Copyright (C) 2015 David King <amigadave amigadave com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "file_tag.h"
+
+#include "misc.h"
+#include "picture.h"
+
+GtkWidget *MainWindow;
+GSettings *MainSettings;
+
+static void
+file_tag_new (void)
+{
+    File_Tag *file_tag;
+
+    file_tag = et_file_tag_new ();
+
+    g_assert (file_tag);
+
+    et_file_tag_free (file_tag);
+}
+
+static void
+file_tag_copy (void)
+{
+    File_Tag *tag1;
+    File_Tag *tag2;
+
+    tag1 = et_file_tag_new ();
+
+    g_assert (tag1);
+
+    et_file_tag_set_title (tag1, "foo");
+    et_file_tag_set_artist (tag1, "bar");
+    et_file_tag_set_album_artist (tag1, "baz");
+
+    g_assert_cmpstr (tag1->title, ==, "foo");
+    g_assert_cmpstr (tag1->artist, ==, "bar");
+    g_assert_cmpstr (tag1->album_artist, ==, "baz");
+
+    tag2 = et_file_tag_new ();
+
+    g_assert (tag2);
+
+    et_file_tag_copy_into (tag2, tag1);
+
+    g_assert_cmpstr (tag2->title, ==, "foo");
+    g_assert_cmpstr (tag2->artist, ==, "bar");
+    g_assert_cmpstr (tag2->album_artist, ==, "baz");
+
+    et_file_tag_free (tag2);
+    et_file_tag_free (tag1);
+}
+
+static void
+file_tag_difference (void)
+{
+    File_Tag *tag1;
+    File_Tag *tag2;
+
+    tag1 = et_file_tag_new ();
+
+    g_assert (tag1);
+
+    et_file_tag_set_title (tag1, "foo");
+    et_file_tag_set_artist (tag1, "bar");
+    et_file_tag_set_album_artist (tag1, "baz");
+
+    g_assert_cmpstr (tag1->title, ==, "foo");
+    g_assert_cmpstr (tag1->artist, ==, "bar");
+    g_assert_cmpstr (tag1->album_artist, ==, "baz");
+
+    tag2 = et_file_tag_new ();
+
+    g_assert (tag2);
+
+    et_file_tag_set_title (tag2, "flub");
+    et_file_tag_set_artist (tag2, "blub");
+    et_file_tag_set_album_artist (tag2, "slub");
+
+    g_assert (et_file_tag_detect_difference (tag1, tag2));
+
+    et_file_tag_free (tag2);
+    et_file_tag_free (tag1);
+}
+
+int
+main (int argc, char** argv)
+{
+    g_test_init (&argc, &argv, NULL);
+
+    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/difference", file_tag_difference);
+
+    return g_test_run ();
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]