Merge branch 'master' into merge-master-to-taglib2

# Conflicts:
#	ConfigureChecks.cmake
#	bindings/c/tag_c.cpp
#	taglib-config.cmd.cmake
#	taglib/asf/asfattribute.cpp
#	taglib/asf/asffile.cpp
#	taglib/audioproperties.cpp
#	taglib/mp4/mp4atom.h
#	taglib/mp4/mp4coverart.cpp
#	taglib/mp4/mp4file.cpp
#	taglib/mp4/mp4item.cpp
#	taglib/mp4/mp4tag.cpp
#	taglib/mpeg/id3v2/id3v2frame.cpp
#	taglib/mpeg/id3v2/id3v2tag.cpp
#	taglib/toolkit/tbytevector.cpp
#	taglib/toolkit/tbytevector.h
#	taglib/toolkit/tfile.cpp
#	taglib/toolkit/tfile.h
#	taglib/toolkit/tlist.h
#	taglib/toolkit/tstring.cpp
#	taglib/toolkit/tstring.h
#	tests/test_apetag.cpp
This commit is contained in:
Tsuda Kageyu
2015-11-19 11:37:18 +09:00
54 changed files with 890 additions and 492 deletions

View File

@ -103,7 +103,7 @@ public:
{
APE::Item item = APE::Item("DUMMY", "Test Text");
CPPUNIT_ASSERT_EQUAL(String("Test Text"), item.toString());
CPPUNIT_ASSERT_EQUAL(ByteVector::null, item.binaryData());
CPPUNIT_ASSERT_EQUAL(ByteVector(), item.binaryData());
ByteVector data("Test Data");
item.setBinaryData(data);
@ -113,7 +113,7 @@ public:
item.setValue("Test Text 2");
CPPUNIT_ASSERT_EQUAL(String("Test Text 2"), item.toString());
CPPUNIT_ASSERT_EQUAL(ByteVector::null, item.binaryData());
CPPUNIT_ASSERT_EQUAL(ByteVector(), item.binaryData());
}
};

View File

@ -43,6 +43,7 @@ class TestByteVector : public CppUnit::TestFixture
CPPUNIT_TEST(testReplace);
CPPUNIT_TEST(testIterator);
CPPUNIT_TEST(testResize);
CPPUNIT_TEST(testAppend);
CPPUNIT_TEST_SUITE_END();
public:
@ -81,6 +82,10 @@ public:
CPPUNIT_ASSERT(i.containsAt(j, 5, 0));
CPPUNIT_ASSERT(i.containsAt(j, 6, 1));
CPPUNIT_ASSERT(i.containsAt(j, 6, 1, 3));
i.clear();
CPPUNIT_ASSERT(i.isEmpty());
CPPUNIT_ASSERT(!i.isNull()); // deprecated, but worth it to check.
}
void testFind1()
@ -292,6 +297,8 @@ public:
*it2 = 'I';
CPPUNIT_ASSERT_EQUAL('i', *it1);
CPPUNIT_ASSERT_EQUAL('I', *it2);
CPPUNIT_ASSERT_EQUAL(ByteVector("taglib"), v1);
CPPUNIT_ASSERT_EQUAL(ByteVector("taglIb"), v2);
ByteVector::ReverseIterator it3 = v1.rbegin();
ByteVector::ReverseIterator it4 = v2.rbegin();
@ -304,6 +311,8 @@ public:
*it4 = 'A';
CPPUNIT_ASSERT_EQUAL('a', *it3);
CPPUNIT_ASSERT_EQUAL('A', *it4);
CPPUNIT_ASSERT_EQUAL(ByteVector("taglib"), v1);
CPPUNIT_ASSERT_EQUAL(ByteVector("tAglIb"), v2);
ByteVector v3;
v3 = ByteVector("0123456789").mid(3, 4);
@ -363,6 +372,20 @@ public:
CPPUNIT_ASSERT_EQUAL(ByteVector::npos, c.find('C'));
}
void testAppend()
{
ByteVector v1("taglib");
ByteVector v2 = v1;
v1.append("ABC");
CPPUNIT_ASSERT_EQUAL(ByteVector("taglibABC"), v1);
v1.append('1');
v1.append('2');
v1.append('3');
CPPUNIT_ASSERT_EQUAL(ByteVector("taglibABC123"), v1);
CPPUNIT_ASSERT_EQUAL(ByteVector("taglib"), v2);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestByteVector);

View File

@ -56,7 +56,7 @@ public:
CPPUNIT_ASSERT_EQUAL(ByteVector("a"), stream.readBlock(1));
CPPUNIT_ASSERT_EQUAL(ByteVector("bc"), stream.readBlock(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("d"), stream.readBlock(3));
CPPUNIT_ASSERT_EQUAL(ByteVector::null, stream.readBlock(3));
CPPUNIT_ASSERT_EQUAL(ByteVector(""), stream.readBlock(3));
}
void testRemoveBlock()

View File

@ -40,7 +40,7 @@ class PublicFrame : public ID3v2::Frame
}
virtual String toString() const { return String::null; }
virtual void parseFields(const ByteVector &) {}
virtual ByteVector renderFields() const { return ByteVector::null; }
virtual ByteVector renderFields() const { return ByteVector(); }
};
class TestID3v2 : public CppUnit::TestFixture

View File

@ -19,6 +19,7 @@ class TestMP4 : public CppUnit::TestFixture
CPPUNIT_TEST(testPropertiesALAC);
CPPUNIT_TEST(testFreeForm);
CPPUNIT_TEST(testCheckValid);
CPPUNIT_TEST(testHasTag);
CPPUNIT_TEST(testIsEmpty);
CPPUNIT_TEST(testUpdateStco);
CPPUNIT_TEST(testSaveExisingWhenIlstIsLast);
@ -67,8 +68,30 @@ public:
{
MP4::File f(TEST_FILE_PATH_C("empty.aiff"));
CPPUNIT_ASSERT(!f.isValid());
MP4::File f2(TEST_FILE_PATH_C("has-tags.m4a"));
CPPUNIT_ASSERT(f2.isValid());
}
void testHasTag()
{
{
MP4::File f(TEST_FILE_PATH_C("has-tags.m4a"));
CPPUNIT_ASSERT(f.isValid());
CPPUNIT_ASSERT(f.hasMP4Tag());
}
ScopedFileCopy copy("no-tags", ".m4a");
{
MP4::File f(copy.fileName().c_str());
CPPUNIT_ASSERT(f.isValid());
CPPUNIT_ASSERT(!f.hasMP4Tag());
f.tag()->setTitle("TITLE");
f.save();
}
{
MP4::File f(copy.fileName().c_str());
CPPUNIT_ASSERT(f.isValid());
CPPUNIT_ASSERT(f.hasMP4Tag());
}
}
void testIsEmpty()
@ -305,6 +328,14 @@ public:
CPPUNIT_ASSERT(f.tag()->contains("cpil"));
CPPUNIT_ASSERT_EQUAL(false, f.tag()->item("cpil").toBool());
CPPUNIT_ASSERT_EQUAL(StringList("0"), tags["COMPILATION"]);
// Empty properties do not result in access violations
// when converting integers
tags["TRACKNUMBER"] = StringList();
tags["DISCNUMBER"] = StringList();
tags["BPM"] = StringList();
tags["COMPILATION"] = StringList();
f.setProperties(tags);
}
void testFuzzedFile()

View File

@ -21,6 +21,7 @@ class TestOGG : public CppUnit::TestFixture
CPPUNIT_TEST(testDictInterface1);
CPPUNIT_TEST(testDictInterface2);
CPPUNIT_TEST(testAudioProperties);
CPPUNIT_TEST(testPageChecksum);
CPPUNIT_TEST_SUITE_END();
public:
@ -134,6 +135,30 @@ public:
CPPUNIT_ASSERT_EQUAL(112000, f.audioProperties()->bitrateNominal());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrateMinimum());
}
void testPageChecksum()
{
ScopedFileCopy copy("empty", ".ogg");
{
Ogg::Vorbis::File f(copy.fileName().c_str());
f.tag()->setArtist("The Artist");
f.save();
f.seek(0x50);
CPPUNIT_ASSERT_EQUAL((TagLib::uint)0x3d3bd92d, f.readBlock(4).toUInt32BE(0));
}
{
Ogg::Vorbis::File f(copy.fileName().c_str());
f.tag()->setArtist("The Artist 2");
f.save();
f.seek(0x50);
CPPUNIT_ASSERT_EQUAL((TagLib::uint)0xd985291c, f.readBlock(4).toUInt32BE(0));
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestOGG);

View File

@ -73,6 +73,10 @@ public:
char str[] = "taglib string";
CPPUNIT_ASSERT(strcmp(s.toCString(), str) == 0);
s.clear();
CPPUNIT_ASSERT(s.isEmpty());
CPPUNIT_ASSERT(!s.isNull());
String unicode("José Carlos", String::UTF8);
CPPUNIT_ASSERT(strcmp(unicode.toCString(), "Jos\xe9 Carlos") == 0);