]> granicus.if.org Git - taglib/commitdiff
Make it possible to run the test suite out of the source tree
authorLukáš Lalinský <lalinsky@gmail.com>
Mon, 11 Apr 2011 16:32:40 +0000 (18:32 +0200)
committerLukáš Lalinský <lalinsky@gmail.com>
Mon, 11 Apr 2011 16:32:40 +0000 (18:32 +0200)
13 files changed:
CMakeLists.txt
config-taglib.h.cmake
tests/test_ape.cpp
tests/test_asf.cpp
tests/test_fileref.cpp
tests/test_flac.cpp
tests/test_id3v2.cpp
tests/test_mp4.cpp
tests/test_mpeg.cpp
tests/test_trueaudio.cpp
tests/test_wav.cpp
tests/test_wavpack.cpp
tests/utils.h

index a70fb78b3f02b057f8125d5ada89b1bb94728965..233f05eb3a562fbf221fe32c1ebc14602f54d2cf 100644 (file)
@@ -12,6 +12,7 @@ option(WITH_ASF "Enable ASF tag reading/writing code"  OFF)
 option(WITH_MP4 "Enable MP4 tag reading/writing code"  OFF)
 
 add_definitions(-DHAVE_CONFIG_H)
+set(TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/")
 
 ## the following are directories where stuff will be installed to
 set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
index a29b932887889c1365b0b7f1192d7b057d8fd2c3..9c2f487d1dea0e501d06f42b7af82c9205e5253a 100644 (file)
@@ -6,3 +6,6 @@
 #cmakedefine   NO_ITUNES_HACKS 1
 #cmakedefine   WITH_ASF 1
 #cmakedefine   WITH_MP4 1
+
+#cmakedefine TESTS_DIR "@TESTS_DIR@"
+
index 10010932f0196d8a121c6ba957b7d6bcead2725f..c95ff0c22d6663719706bc2a29154bb39da77a54 100644 (file)
@@ -22,7 +22,7 @@ public:
 
   void testProperties399()
   {
-    APE::File f("data/mac-399.ape");
+    APE::File f(TEST_FILE_PATH_C("mac-399.ape"));
     CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
     CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
     CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
@@ -31,7 +31,7 @@ public:
 
   void testProperties396()
   {
-    APE::File f("data/mac-396.ape");
+    APE::File f(TEST_FILE_PATH_C("mac-396.ape"));
     CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
     CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
     CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
@@ -40,7 +40,7 @@ public:
 
   void testProperties390()
   {
-    APE::File f("data/mac-390-hdr.ape");
+    APE::File f(TEST_FILE_PATH_C("mac-390-hdr.ape"));
     CPPUNIT_ASSERT_EQUAL(15, f.audioProperties()->length());
     CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
     CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
index d93dcb479f6199a8afe6dcb6dd5a09fa6821b176..bcebc164734071e971a31daa5322b06974ad6755 100644 (file)
@@ -28,7 +28,7 @@ public:
 
   void testProperties()
   {
-    ASF::File f("data/silence-1.wma");
+    ASF::File f(TEST_FILE_PATH_C("silence-1.wma"));
     CPPUNIT_ASSERT_EQUAL(4, f.audioProperties()->length());
     CPPUNIT_ASSERT_EQUAL(64, f.audioProperties()->bitrate());
     CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
@@ -37,7 +37,7 @@ public:
 
   void testRead()
   {
-    ASF::File f("data/silence-1.wma");
+    ASF::File f(TEST_FILE_PATH_C("silence-1.wma"));
     CPPUNIT_ASSERT_EQUAL(String("test"), f.tag()->title());
   }
 
index 965afa9a0bb12cdf0b995c46a9f332734541890e..fb8b2458ffce8e806b2acb7872fc31a914848cba 100644 (file)
@@ -137,14 +137,14 @@ public:
 
   void testOGA_FLAC()
   {
-      FileRef *f = new FileRef("data/empty_flac.oga");
+      FileRef *f = new FileRef(TEST_FILE_PATH_C("empty_flac.oga"));
       CPPUNIT_ASSERT(dynamic_cast<Ogg::Vorbis::File *>(f->file()) == NULL);
       CPPUNIT_ASSERT(dynamic_cast<Ogg::FLAC::File *>(f->file()) != NULL);
   }
 
   void testOGA_Vorbis()
   {
-      FileRef *f = new FileRef("data/empty_vorbis.oga");
+      FileRef *f = new FileRef(TEST_FILE_PATH_C("empty_vorbis.oga"));
       CPPUNIT_ASSERT(dynamic_cast<Ogg::Vorbis::File *>(f->file()) != NULL);
       CPPUNIT_ASSERT(dynamic_cast<Ogg::FLAC::File *>(f->file()) == NULL);
   }
index 4b54a7cafdd7451be1d57767451ea09e768be58c..d93150a335917ca355afa49888b7739cf5a4b2e5 100644 (file)
@@ -28,7 +28,7 @@ public:
 
   void testSignature()
   {
-    FLAC::File f("data/no-tags.flac");
+    FLAC::File f(TEST_FILE_PATH_C("no-tags.flac"));
     CPPUNIT_ASSERT_EQUAL(ByteVector("a1b141f766e9849ac3db1030a20a3c77"), f.audioProperties()->signature().toHex());
   }
 
index 8b8939b329c06c662ab3bd333665b7c5ec40b998..5b2151add1eec5ff5b8a3b5eb18c4381e54742b3 100644 (file)
@@ -73,7 +73,7 @@ public:
 
   void testUnsynchDecode()
   {
-    MPEG::File f("data/unsynch.id3", false);
+    MPEG::File f(TEST_FILE_PATH_C("unsynch.id3"), false);
     CPPUNIT_ASSERT(f.tag());
     CPPUNIT_ASSERT_EQUAL(String("My babe just cares for me"), f.tag()->title());
   }
@@ -114,7 +114,7 @@ public:
 
   void testBrokenFrame1()
   {
-    MPEG::File f("data/broken-tenc.id3", false);
+    MPEG::File f(TEST_FILE_PATH_C("broken-tenc.id3"), false);
     CPPUNIT_ASSERT(f.tag());
     CPPUNIT_ASSERT(!f.ID3v2Tag()->frameListMap().contains("TENC"));
   }
@@ -382,7 +382,7 @@ public:
 
   void testItunes24FrameSize()
   {
-    MPEG::File f("data/005411.id3", false);
+    MPEG::File f(TEST_FILE_PATH_C("005411.id3"), false);
     CPPUNIT_ASSERT(f.tag());
     CPPUNIT_ASSERT(f.ID3v2Tag()->frameListMap().contains("TIT2"));
     CPPUNIT_ASSERT_EQUAL(String("Sunshine Superman"), f.ID3v2Tag()->frameListMap()["TIT2"].front()->toString());
@@ -463,14 +463,14 @@ public:
 
   void testUpdateDate22()
   {
-    MPEG::File f("data/id3v22-tda.mp3", false);
+    MPEG::File f(TEST_FILE_PATH_C("id3v22-tda.mp3"), false);
     CPPUNIT_ASSERT(f.tag());
     CPPUNIT_ASSERT_EQUAL(TagLib::uint(2010), f.tag()->year());
   }
 
   void testUpdateFullDate22()
   {
-    MPEG::File f("data/id3v22-tda.mp3", false);
+    MPEG::File f(TEST_FILE_PATH_C("id3v22-tda.mp3"), false);
     CPPUNIT_ASSERT(f.tag());
     CPPUNIT_ASSERT_EQUAL(String("2010-04-03"), f.ID3v2Tag()->frameListMap()["TDRC"].front()->toString());
   }
@@ -536,7 +536,7 @@ public:
 
   void testCompressedFrameWithBrokenLength()
   {
-    MPEG::File f("data/compressed_id3_frame.mp3", false);
+    MPEG::File f(TEST_FILE_PATH_C("compressed_id3_frame.mp3"), false);
     CPPUNIT_ASSERT(f.ID3v2Tag()->frameListMap().contains("APIC"));
     ID3v2::AttachedPictureFrame *frame =
         static_cast<TagLib::ID3v2::AttachedPictureFrame*>(f.ID3v2Tag()->frameListMap()["APIC"].front());
index 31ea60964c808753ef72a600f4866fb34759254b..1e7f8f5a87498160076fd3668d3e936ef921f415 100644 (file)
@@ -30,7 +30,7 @@ public:
 
   void testProperties()
   {
-    MP4::File f("data/has-tags.m4a");
+    MP4::File f(TEST_FILE_PATH_C("has-tags.m4a"));
     CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
     CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->bitrate());
     CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
@@ -40,9 +40,9 @@ public:
 
   void testCheckValid()
   {
-    MP4::File f("data/empty.aiff");
+    MP4::File f(TEST_FILE_PATH_C("empty.aiff"));
     CPPUNIT_ASSERT(!f.isValid());
-    MP4::File f2("data/has-tags.m4a");
+    MP4::File f2(TEST_FILE_PATH_C("has-tags.m4a"));
     CPPUNIT_ASSERT(f2.isValid());
   }
 
@@ -156,14 +156,14 @@ public:
 
   void testGnre()
   {
-    MP4::File *f = new MP4::File("data/gnre.m4a");
+    MP4::File *f = new MP4::File(TEST_FILE_PATH_C("gnre.m4a"));
     CPPUNIT_ASSERT_EQUAL(TagLib::String("Ska"), f->tag()->genre());
     delete f;
   }
 
   void testCovrRead()
   {
-    MP4::File *f = new MP4::File("data/has-tags.m4a");
+    MP4::File *f = new MP4::File(TEST_FILE_PATH_C("has-tags.m4a"));
     CPPUNIT_ASSERT(f->tag()->itemListMap().contains("covr"));
     MP4::CoverArtList l = f->tag()->itemListMap()["covr"].toCoverArtList();
     CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), l.size());
@@ -202,7 +202,7 @@ public:
 
   void testCovrRead2()
   {
-    MP4::File *f = new MP4::File("data/covr-junk.m4a");
+    MP4::File *f = new MP4::File(TEST_FILE_PATH_C("covr-junk.m4a"));
     CPPUNIT_ASSERT(f->tag()->itemListMap().contains("covr"));
     MP4::CoverArtList l = f->tag()->itemListMap()["covr"].toCoverArtList();
     CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), l.size());
index 754caa98d887936b417a1a7e8d33df1f54c4b89e..973803f908d78b9597ef87098a7f079507f26508 100644 (file)
@@ -21,7 +21,7 @@ public:
 
   void testVersion2DurationWithXingHeader()
   {
-    MPEG::File f("data/mpeg2.mp3");
+    MPEG::File f(TEST_FILE_PATH_C("mpeg2.mp3"));
     CPPUNIT_ASSERT_EQUAL(5387, f.audioProperties()->length());
   }
 
index b300eef9e3ddf2e49334a95cd3bc5381b0477be2..5ff114cf02b670e76ec338b0ab3ea72372f5ae74 100644 (file)
@@ -2,6 +2,7 @@
 #include <string>
 #include <stdio.h>
 #include <trueaudiofile.h>
+#include "utils.h"
 
 using namespace std;
 using namespace TagLib;
@@ -16,7 +17,7 @@ public:
 
   void testReadPropertiesWithoutID3v2()
   {
-    TrueAudio::File f("data/empty.tta");
+    TrueAudio::File f(TEST_FILE_PATH_C("empty.tta"));
     CPPUNIT_ASSERT(f.audioProperties());
     CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
   }
index 38a9a0fbc1f62c92f81b90d2851343c08496c5ae..c4e5f39008d6483d25b91d85f2534fe7819b8657 100644 (file)
@@ -19,7 +19,7 @@ public:
 
   void testLength()
   {
-    RIFF::WAV::File f("data/empty.wav");
+    RIFF::WAV::File f(TEST_FILE_PATH_C("empty.wav"));
     CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
   }
 
index 03e60202ee591dcf269b5cfa7c02ccd41e498871..085fa2daa2fb3d0bd9a246a3de6756cebc3e5819 100644 (file)
@@ -20,7 +20,7 @@ public:
 
   void testBasic()
   {
-    WavPack::File f("data/no_length.wv");
+    WavPack::File f(TEST_FILE_PATH_C("no_length.wv"));
     WavPack::Properties *props = f.audioProperties();
     CPPUNIT_ASSERT_EQUAL(44100, props->sampleRate());
     CPPUNIT_ASSERT_EQUAL(2, props->channels());
@@ -30,7 +30,7 @@ public:
 
   void testLengthScan()
   {
-    WavPack::File f("data/no_length.wv");
+    WavPack::File f(TEST_FILE_PATH_C("no_length.wv"));
     WavPack::Properties *props = f.audioProperties();
     CPPUNIT_ASSERT_EQUAL(4, props->length());
   }
index dece293f986cd325b0a34fd807df087d318cd833..57226efc95807dac8a9dc93b6b6c86ede00f1531 100644 (file)
@@ -1,3 +1,6 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 #ifdef _WIN32
 #include <windows.h>
 #else
 
 using namespace std;
 
+inline string testFilePath(const string &filename)
+{
+  return string(TESTS_DIR "data/") + filename;
+}
+
+#define TEST_FILE_PATH_C(f) testFilePath(f).c_str()
+
 inline string copyFile(const string &filename, const string &ext)
 {
   string newname = string(tempnam(NULL, NULL)) + ext;
-  string oldname = string("data/") + filename + ext;
+  string oldname = testFilePath(filename) + ext;
 #ifdef _WIN32
   CopyFile(oldname.c_str(), newname.c_str(), FALSE);
   SetFileAttributes(newname.c_str(), GetFileAttributes(newname.c_str()) & ~FILE_ATTRIBUTE_READONLY);