[easytag] Add an ID3 genre number test



commit 03cce6dbc403e45d6a27da68dbc3f1591eb4a4ab
Author: David King <amigadave amigadave com>
Date:   Sat Nov 5 21:09:43 2016 +0000

    Add an ID3 genre number test
    
    Test that the expected genre IDs convert to appropriate strings (not
    the "Unknown" placeholder), that the index of the final expected genre
    is correct and finally that all unexpected genres are reported as
    "Unknown".

 Makefile.am         |   13 +++++++++++++
 tests/test-genres.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 7ef7686..7f4ba1d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -442,6 +442,7 @@ test-report perf-report full-report: $(check_PROGRAMS)
 
 check_PROGRAMS = \
        tests/test-dlm \
+       tests/test-genres \
        tests/test-file_description \
        tests/test-file_info \
        tests/test-file_tag \
@@ -514,6 +515,18 @@ tests_test_file_tag_SOURCES = \
 tests_test_file_tag_LDADD = \
        $(EASYTAG_LIBS)
 
+tests_test_genres_CPPFLAGS = \
+       $(common_test_cppflags)
+
+tests_test_genres_CFLAGS = \
+       $(common_test_cflags)
+
+tests_test_genres_SOURCES = \
+       tests/test-genres.c
+
+tests_test_genres_LDADD = \
+       $(EASYTAG_LIBS)
+
 tests_test_misc_CPPFLAGS = \
        $(common_test_cppflags) \
        -I$(top_srcdir)/src/tags
diff --git a/tests/test-genres.c b/tests/test-genres.c
new file mode 100644
index 0000000..faea0db
--- /dev/null
+++ b/tests/test-genres.c
@@ -0,0 +1,49 @@
+/* EasyTAG - tag editor for audio files
+ * Copyright (C) 2016 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 <glib.h>
+
+#include "genres.h"
+
+static void
+genres_genre_no (void)
+{
+    gsize i;
+
+    for (i = 0; i < G_N_ELEMENTS (id3_genres); i++)
+    {
+        g_assert_cmpstr (genre_no (i), !=, "Unknown");
+    }
+
+    g_assert_cmpint (i, ==, GENRE_MAX + 1);
+
+    for (; i < 255; i++)
+    {
+        g_assert_cmpstr (genre_no (i), ==, "Unknown");
+    }
+}
+
+int
+main (int argc, char** argv)
+{
+    g_test_init (&argc, &argv, NULL);
+
+    g_test_add_func ("/genres/genre_no", genres_genre_no);
+
+    return g_test_run ();
+}


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