mirror of
https://github.com/taglib/taglib.git
synced 2025-07-23 15:34:30 -04:00
Merge branch 'master' into merge-master-to-taglib2
# Conflicts: # ConfigureChecks.cmake # taglib/CMakeLists.txt # taglib/asf/asfattribute.cpp # taglib/it/itproperties.cpp # taglib/mod/modproperties.cpp # taglib/mpeg/mpegfile.cpp # taglib/mpeg/mpegproperties.cpp # taglib/ogg/flac/oggflacfile.cpp # taglib/s3m/s3mproperties.cpp # taglib/tagunion.cpp # taglib/toolkit/tfile.cpp # taglib/toolkit/trefcounter.h # taglib/toolkit/tstring.cpp # taglib/xm/xmproperties.cpp # tests/test_mpeg.cpp
This commit is contained in:
BIN
tests/data/empty-seektable.flac
Normal file
BIN
tests/data/empty-seektable.flac
Normal file
Binary file not shown.
BIN
tests/data/garbage.mp3
Normal file
BIN
tests/data/garbage.mp3
Normal file
Binary file not shown.
Binary file not shown.
@ -233,7 +233,7 @@ public:
|
||||
FileRef f1(TEST_FILE_PATH_C("no-extension"));
|
||||
CPPUNIT_ASSERT(f1.isNull());
|
||||
|
||||
FileRef f2(TEST_FILE_PATH_C("unsupported-extension.xxx"));
|
||||
FileRef f2(TEST_FILE_PATH_C("unsupported-extension.xx"));
|
||||
CPPUNIT_ASSERT(f2.isNull());
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@ class TestFLAC : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testEmptyID3v2);
|
||||
CPPUNIT_TEST(testStripTags);
|
||||
CPPUNIT_TEST(testRemoveXiphField);
|
||||
CPPUNIT_TEST(testEmptySeekTable);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -516,6 +517,24 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void testEmptySeekTable()
|
||||
{
|
||||
ScopedFileCopy copy("empty-seektable", ".flac");
|
||||
{
|
||||
FLAC::File f(copy.fileName().c_str());
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
f.xiphComment(true)->setTitle("XiphComment Title");
|
||||
f.save();
|
||||
}
|
||||
{
|
||||
FLAC::File f(copy.fileName().c_str());
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
f.seek(42);
|
||||
const ByteVector data = f.readBlock(4);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\x03\x00\x00\x00", 4), data);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestFLAC);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/***************************************************************************
|
||||
/***************************************************************************
|
||||
copyright : (C) 2007 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
@ -64,6 +64,7 @@ class TestMPEG : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testEmptyID3v2);
|
||||
CPPUNIT_TEST(testEmptyID3v1);
|
||||
CPPUNIT_TEST(testEmptyAPE);
|
||||
CPPUNIT_TEST(testIgnoreGarbage);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -96,7 +97,7 @@ public:
|
||||
|
||||
void testAudioPropertiesVBRIHeader()
|
||||
{
|
||||
MPEG::File f(TEST_FILE_PATH_C("vbri.mp3"));
|
||||
MPEG::File f(TEST_FILE_PATH_C("rare_frames.mp3"));
|
||||
CPPUNIT_ASSERT(f.audioProperties());
|
||||
CPPUNIT_ASSERT_EQUAL(222, f.audioProperties()->length());
|
||||
CPPUNIT_ASSERT_EQUAL(222, f.audioProperties()->lengthInSeconds());
|
||||
@ -119,13 +120,8 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
|
||||
CPPUNIT_ASSERT(!f.audioProperties()->xingHeader());
|
||||
|
||||
long long last = f.lastFrameOffset();
|
||||
MPEG::Header lastHeader(&f, last, false);
|
||||
|
||||
while(!lastHeader.isValid()) {
|
||||
last = f.previousFrameOffset(last);
|
||||
lastHeader = MPEG::Header(&f, last, false);
|
||||
}
|
||||
const long long last = f.lastFrameOffset();
|
||||
const MPEG::Header lastHeader(&f, last, false);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(28213LL, last);
|
||||
CPPUNIT_ASSERT_EQUAL(209, lastHeader.frameLength());
|
||||
@ -163,7 +159,7 @@ public:
|
||||
CPPUNIT_ASSERT(f.audioProperties());
|
||||
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->length());
|
||||
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->lengthInSeconds());
|
||||
CPPUNIT_ASSERT_EQUAL(176, f.audioProperties()->lengthInMilliseconds());
|
||||
CPPUNIT_ASSERT_EQUAL(183, f.audioProperties()->lengthInMilliseconds());
|
||||
CPPUNIT_ASSERT_EQUAL(320, f.audioProperties()->bitrate());
|
||||
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
|
||||
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
|
||||
@ -421,6 +417,27 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void testIgnoreGarbage()
|
||||
{
|
||||
const ScopedFileCopy copy("garbage", ".mp3");
|
||||
{
|
||||
MPEG::File f(copy.fileName().c_str());
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
CPPUNIT_ASSERT_EQUAL(2255LL, f.firstFrameOffset());
|
||||
CPPUNIT_ASSERT_EQUAL(6015LL, f.lastFrameOffset());
|
||||
CPPUNIT_ASSERT_EQUAL(String("Title A"), f.ID3v2Tag()->title());
|
||||
f.ID3v2Tag()->setTitle("Title B");
|
||||
f.save();
|
||||
}
|
||||
{
|
||||
MPEG::File f(copy.fileName().c_str());
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
CPPUNIT_ASSERT_EQUAL(String("Title B"), f.ID3v2Tag()->title());
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestMPEG);
|
||||
|
@ -49,8 +49,9 @@ class TestString : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testUpper);
|
||||
CPPUNIT_TEST(testEncodeNonLatin1);
|
||||
CPPUNIT_TEST(testEncodeEmpty);
|
||||
CPPUNIT_TEST(testEncodeNonBMP);
|
||||
CPPUNIT_TEST(testIterator);
|
||||
CPPUNIT_TEST(testRedundantUTF8);
|
||||
CPPUNIT_TEST(testInvalidUTF8);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -174,6 +175,15 @@ public:
|
||||
|
||||
const String s2(v2, String::UTF8);
|
||||
CPPUNIT_ASSERT_EQUAL(s2.data(String::UTF16), v1);
|
||||
|
||||
const ByteVector v3("\xfe\xff\xd8\x01\x30\x42");
|
||||
CPPUNIT_ASSERT(String(v3, String::UTF16).data(String::UTF8).isEmpty());
|
||||
|
||||
const ByteVector v4("\xfe\xff\x30\x42\xdc\x01");
|
||||
CPPUNIT_ASSERT(String(v4, String::UTF16).data(String::UTF8).isEmpty());
|
||||
|
||||
const ByteVector v5("\xfe\xff\xdc\x01\xd8\x01");
|
||||
CPPUNIT_ASSERT(String(v5, String::UTF16).data(String::UTF8).isEmpty());
|
||||
}
|
||||
|
||||
void testAppendStringDetach()
|
||||
@ -321,6 +331,13 @@ public:
|
||||
CPPUNIT_ASSERT(empty.to8Bit(true).empty());
|
||||
}
|
||||
|
||||
void testEncodeNonBMP()
|
||||
{
|
||||
const ByteVector a("\xFF\xFE\x3C\xD8\x50\xDD\x40\xD8\xF5\xDC\x3C\xD8\x00\xDE", 14);
|
||||
const ByteVector b("\xF0\x9F\x85\x90\xF0\xA0\x83\xB5\xF0\x9F\x88\x80");
|
||||
CPPUNIT_ASSERT_EQUAL(b, String(a, String::UTF16).data(String::UTF8));
|
||||
}
|
||||
|
||||
void testIterator()
|
||||
{
|
||||
String s1 = "taglib string";
|
||||
@ -339,12 +356,26 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(L'I', *it2);
|
||||
}
|
||||
|
||||
void testRedundantUTF8()
|
||||
void testInvalidUTF8()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(String("/"), String(ByteVector("\x2F"), String::UTF8));
|
||||
CPPUNIT_ASSERT(String(ByteVector("\xC0\xAF"), String::UTF8).isEmpty());
|
||||
CPPUNIT_ASSERT(String(ByteVector("\xE0\x80\xAF"), String::UTF8).isEmpty());
|
||||
CPPUNIT_ASSERT(String(ByteVector("\xF0\x80\x80\xAF"), String::UTF8).isEmpty());
|
||||
|
||||
CPPUNIT_ASSERT(String(ByteVector("\xF8\x80\x80\x80\x80"), String::UTF8).isEmpty());
|
||||
CPPUNIT_ASSERT(String(ByteVector("\xFC\x80\x80\x80\x80\x80"), String::UTF8).isEmpty());
|
||||
|
||||
CPPUNIT_ASSERT(String(ByteVector("\xC2"), String::UTF8).isEmpty());
|
||||
CPPUNIT_ASSERT(String(ByteVector("\xE0\x80"), String::UTF8).isEmpty());
|
||||
CPPUNIT_ASSERT(String(ByteVector("\xF0\x80\x80"), String::UTF8).isEmpty());
|
||||
CPPUNIT_ASSERT(String(ByteVector("\xF8\x80\x80\x80"), String::UTF8).isEmpty());
|
||||
CPPUNIT_ASSERT(String(ByteVector("\xFC\x80\x80\x80\x80"), String::UTF8).isEmpty());
|
||||
|
||||
CPPUNIT_ASSERT(String('\x80', String::UTF8).isEmpty());
|
||||
|
||||
CPPUNIT_ASSERT(String(ByteVector("\xED\xA0\x80\xED\xB0\x80"), String::UTF8).isEmpty());
|
||||
CPPUNIT_ASSERT(String(ByteVector("\xED\xB0\x80\xED\xA0\x80"), String::UTF8).isEmpty());
|
||||
}
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user