diff options
author | Lukáš Lalinský <lalinsky@gmail.com> | 2011-04-11 18:32:40 +0200 |
---|---|---|
committer | Lukáš Lalinský <lalinsky@gmail.com> | 2011-04-11 18:32:40 +0200 |
commit | 4cda0eeb7b4b58ac076b9b174f9a8dff7e717fc0 (patch) | |
tree | cd4e53a287993ce1bc9f0fe9898701fdca3e0e57 /tests | |
parent | 2fa8c93776f2677033399a193596a16b9b4a7e52 (diff) |
Make it possible to run the test suite out of the source tree
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_ape.cpp | 6 | ||||
-rw-r--r-- | tests/test_asf.cpp | 4 | ||||
-rw-r--r-- | tests/test_fileref.cpp | 4 | ||||
-rw-r--r-- | tests/test_flac.cpp | 2 | ||||
-rw-r--r-- | tests/test_id3v2.cpp | 12 | ||||
-rw-r--r-- | tests/test_mp4.cpp | 12 | ||||
-rw-r--r-- | tests/test_mpeg.cpp | 2 | ||||
-rw-r--r-- | tests/test_trueaudio.cpp | 3 | ||||
-rw-r--r-- | tests/test_wav.cpp | 2 | ||||
-rw-r--r-- | tests/test_wavpack.cpp | 4 | ||||
-rw-r--r-- | tests/utils.h | 12 |
11 files changed, 37 insertions, 26 deletions
diff --git a/tests/test_ape.cpp b/tests/test_ape.cpp index 10010932..c95ff0c2 100644 --- a/tests/test_ape.cpp +++ b/tests/test_ape.cpp @@ -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()); diff --git a/tests/test_asf.cpp b/tests/test_asf.cpp index d93dcb47..bcebc164 100644 --- a/tests/test_asf.cpp +++ b/tests/test_asf.cpp @@ -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()); } diff --git a/tests/test_fileref.cpp b/tests/test_fileref.cpp index 965afa9a..fb8b2458 100644 --- a/tests/test_fileref.cpp +++ b/tests/test_fileref.cpp @@ -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); } diff --git a/tests/test_flac.cpp b/tests/test_flac.cpp index 4b54a7ca..d93150a3 100644 --- a/tests/test_flac.cpp +++ b/tests/test_flac.cpp @@ -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()); } diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index 8b8939b3..5b2151ad 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -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()); diff --git a/tests/test_mp4.cpp b/tests/test_mp4.cpp index 31ea6096..1e7f8f5a 100644 --- a/tests/test_mp4.cpp +++ b/tests/test_mp4.cpp @@ -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()); diff --git a/tests/test_mpeg.cpp b/tests/test_mpeg.cpp index 754caa98..973803f9 100644 --- a/tests/test_mpeg.cpp +++ b/tests/test_mpeg.cpp @@ -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()); } diff --git a/tests/test_trueaudio.cpp b/tests/test_trueaudio.cpp index b300eef9..5ff114cf 100644 --- a/tests/test_trueaudio.cpp +++ b/tests/test_trueaudio.cpp @@ -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()); } diff --git a/tests/test_wav.cpp b/tests/test_wav.cpp index 38a9a0fb..c4e5f390 100644 --- a/tests/test_wav.cpp +++ b/tests/test_wav.cpp @@ -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()); } diff --git a/tests/test_wavpack.cpp b/tests/test_wavpack.cpp index 03e60202..085fa2da 100644 --- a/tests/test_wavpack.cpp +++ b/tests/test_wavpack.cpp @@ -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()); } diff --git a/tests/utils.h b/tests/utils.h index dece293f..57226efc 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -1,3 +1,6 @@ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #ifdef _WIN32 #include <windows.h> #else @@ -10,10 +13,17 @@ 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); |