[easytag] Add simple test for Convert_Duration()
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Add simple test for Convert_Duration()
- Date: Fri, 21 Nov 2014 16:53:05 +0000 (UTC)
commit d5c3569e076486c46ce1d4a3a86476c4c00553d8
Author: David King <amigadave amigadave com>
Date: Fri Nov 21 16:38:26 2014 +0000
Add simple test for Convert_Duration()
Makefile.am | 18 ++++++++++++++++
tests/test-misc.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 0 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 4c1a261..57fafa9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -408,8 +408,26 @@ test-report perf-report full-report: $(check_PROGRAMS)
}
check_PROGRAMS = \
+ tests/test-misc \
tests/test-scan
+tests_test_misc_CPPFLAGS = \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/tags \
+ -I$(top_builddir) \
+ $(DEPRECATED_CPPFLAGS)
+
+tests_test_misc_CFLAGS = \
+ $(WARN_CFLAGS) \
+ $(EASYTAG_CFLAGS)
+
+tests_test_misc_SOURCES = \
+ tests/test-misc.c \
+ src/misc.c
+
+tests_test_misc_LDADD = \
+ $(EASYTAG_LIBS)
+
tests_test_scan_CPPFLAGS = \
-I$(top_srcdir)/src \
-I$(top_builddir) \
diff --git a/tests/test-misc.c b/tests/test-misc.c
new file mode 100644
index 0000000..543d2b1
--- /dev/null
+++ b/tests/test-misc.c
@@ -0,0 +1,59 @@
+/* EasyTAG - tag editor for audio files
+ * Copyright (C) 2014 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 "misc.h"
+
+static void
+misc_convert_duration (void)
+{
+ gsize i;
+ gchar *time;
+
+ static const struct
+ {
+ const gulong seconds;
+ const gchar *result;
+ } times[] =
+ {
+ { 0, "0:00" },
+ { 10, "0:10" },
+ { 100, "1:40" },
+ { 1000, "16:40" },
+ { 10000, "2:46:40" },
+ { 100000, "27:46:40" },
+ { 1000000, "277:46:40" }
+ /* TODO: Add more tests. */
+ };
+
+ for (i = 0; i < G_N_ELEMENTS (times); i++)
+ {
+ time = Convert_Duration (times[i].seconds);
+ g_assert_cmpstr (time, ==, times[i].result);
+ g_free (time);
+ }
+}
+
+int
+main (int argc, char** argv)
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/misc/convert-duration", misc_convert_duration);
+
+ return g_test_run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]