gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r23239 - in Extractor/src/plugins: . testdata


From: gnunet
Subject: [GNUnet-SVN] r23239 - in Extractor/src/plugins: . testdata
Date: Wed, 15 Aug 2012 00:56:55 +0200

Author: grothoff
Date: 2012-08-15 00:56:55 +0200 (Wed, 15 Aug 2012)
New Revision: 23239

Added:
   Extractor/src/plugins/test_xm.c
   Extractor/src/plugins/testdata/xm_diesel.xm
Modified:
   Extractor/src/plugins/Makefile.am
   Extractor/src/plugins/xm_extractor.c
Log:
xm testcase


Modified: Extractor/src/plugins/Makefile.am
===================================================================
--- Extractor/src/plugins/Makefile.am   2012-08-14 22:32:03 UTC (rev 23238)
+++ Extractor/src/plugins/Makefile.am   2012-08-14 22:56:55 UTC (rev 23239)
@@ -34,7 +34,8 @@
   testdata/odf_cg.odt \
   testdata/deb_bzip2.deb \
   testdata/nsf_arkanoid.nsf \
-  testdata/nsfe_classics.nsfe
+  testdata/nsfe_classics.nsfe \
+  testdata/xm_diesel.xm
 
 if HAVE_VORBISFILE
 PLUGIN_OGG=libextractor_ogg.la
@@ -119,6 +120,7 @@
   test_png \
   test_odf \
   test_zip \
+  test_xm \
   test_nsf \
   test_nsfe \
   $(TEST_ZLIB) \
@@ -151,7 +153,12 @@
 libextractor_xm_la_LDFLAGS = \
   $(PLUGINFLAGS)
 
+test_xm_SOURCES = \
+  test_xm.c
+test_xm_LDADD = \
+  $(top_builddir)/src/plugins/libtest.la
 
+
 libextractor_deb_la_SOURCES = \
   deb_extractor.c
 libextractor_deb_la_LDFLAGS = \
@@ -240,6 +247,7 @@
 libextractor_sid_la_LDFLAGS = \
   $(PLUGINFLAGS)
 
+
 libextractor_s3m_la_SOURCES = \
   s3m_extractor.c
 libextractor_s3m_la_LDFLAGS = \

Added: Extractor/src/plugins/test_xm.c
===================================================================
--- Extractor/src/plugins/test_xm.c                             (rev 0)
+++ Extractor/src/plugins/test_xm.c     2012-08-14 22:56:55 UTC (rev 23239)
@@ -0,0 +1,85 @@
+/*
+     This file is part of libextractor.
+     (C) 2012 Vidyut Samanta and Christian Grothoff
+
+     libextractor 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 3, or (at your
+     option) any later version.
+
+     libextractor 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 libextractor; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file plugins/test_xm.c
+ * @brief testcase for xm plugin
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "test_lib.h"
+
+
+
+/**
+ * Main function for the XM testcase.
+ *
+ * @param argc number of arguments (ignored)
+ * @param argv arguments (ignored)
+ * @return 0 on success
+ */
+int
+main (int argc, char *argv[])
+{
+  struct SolutionData xm_diesel_sol[] =
+    {
+      { 
+       EXTRACTOR_METATYPE_MIMETYPE,
+       EXTRACTOR_METAFORMAT_UTF8,
+       "text/plain",
+       "audio/x-xm",
+       strlen ("audio/x-xm") + 1,
+       0 
+      },
+      { 
+       EXTRACTOR_METATYPE_FORMAT_VERSION,
+       EXTRACTOR_METAFORMAT_UTF8,
+       "text/plain",
+       "1.4",
+       strlen ("1.4") + 1,
+       0 
+      },
+      { 
+       EXTRACTOR_METATYPE_TITLE,
+       EXTRACTOR_METAFORMAT_UTF8,
+       "text/plain",
+       "diesel",
+       strlen ("diesel") + 1,
+       0 
+      },
+      { 
+       EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
+       EXTRACTOR_METAFORMAT_UTF8,
+       "text/plain",
+       "FastTracker v2.00",
+       strlen ("FastTracker v2.00") + 1,
+       0 
+      },
+      { 0, 0, NULL, NULL, 0, -1 }
+    };
+  struct ProblemSet ps[] =
+    {
+      { "testdata/xm_diesel.xm",
+       xm_diesel_sol },
+      { NULL, NULL }
+    };
+  return ET_main ("xm", ps);
+}
+
+/* end of test_xm.c */

Added: Extractor/src/plugins/testdata/xm_diesel.xm
===================================================================
(Binary files differ)


Property changes on: Extractor/src/plugins/testdata/xm_diesel.xm
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: Extractor/src/plugins/xm_extractor.c
===================================================================
--- Extractor/src/plugins/xm_extractor.c        2012-08-14 22:32:03 UTC (rev 
23238)
+++ Extractor/src/plugins/xm_extractor.c        2012-08-14 22:56:55 UTC (rev 
23239)
@@ -68,6 +68,7 @@
   char title[21];
   char tracker[21];
   char xmversion[8];
+  size_t n;
 
   if (sizeof (struct Header) >
       ec->read (ec->cls,
@@ -88,11 +89,17 @@
   ADD (xmversion, EXTRACTOR_METATYPE_FORMAT_VERSION);
   /* Song title */
   memcpy (&title, head->title, 20);
-  title[20] = '\0';
+  n = 19;
+  while ( (n > 0) && isspace ((unsigned char) title[n]))
+    n--;
+  title[n + 1] = '\0';
   ADD (title, EXTRACTOR_METATYPE_TITLE);
   /* software used for creating the data */
   memcpy (&tracker, head->tracker, 20);
-  tracker[20] = '\0';
+  n = 19;
+  while ( (n > 0) && isspace ((unsigned char) tracker[n]))
+    n--;
+  tracker[n + 1] = '\0'; 
   ADD (tracker, EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE);
   return;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]