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

# Conflicts:
#	taglib/ape/apefile.cpp
#	taglib/ape/apefile.h
#	taglib/fileref.cpp
#	taglib/flac/flacfile.cpp
#	taglib/flac/flacfile.h
#	taglib/mpc/mpcfile.cpp
#	taglib/mpc/mpcfile.h
#	taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp
#	taglib/mpeg/id3v2/id3v2frame.cpp
#	taglib/tagunion.cpp
#	taglib/toolkit/tiostream.cpp
#	taglib/trueaudio/trueaudiofile.cpp
#	taglib/trueaudio/trueaudiofile.h
#	taglib/wavpack/wavpackfile.cpp
#	taglib/wavpack/wavpackfile.h
#	tests/test_fileref.cpp
#	tests/test_id3v2.cpp
This commit is contained in:
Tsuda Kageyu
2015-11-21 20:22:07 +09:00
51 changed files with 460 additions and 403 deletions

View File

@ -108,7 +108,7 @@ public:
ByteVector data("Test Data");
item.setBinaryData(data);
CPPUNIT_ASSERT(item.values().isEmpty());
CPPUNIT_ASSERT_EQUAL(String::null, item.toString());
CPPUNIT_ASSERT_EQUAL(String(), item.toString());
CPPUNIT_ASSERT_EQUAL(data, item.binaryData());
item.setValue("Test Text 2");

View File

@ -4,12 +4,26 @@
#include <fileref.h>
#include <oggflacfile.h>
#include <vorbisfile.h>
#include <mpegfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
#include <tfilestream.h>
using namespace std;
using namespace TagLib;
namespace
{
class DummyResolver : public FileRef::FileTypeResolver
{
public:
virtual File *createFile(FileName fileName, bool, AudioProperties::ReadStyle) const
{
return new Ogg::Vorbis::File(fileName);
}
};
}
class TestFileRef : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestFileRef);
@ -30,6 +44,7 @@ class TestFileRef : public CppUnit::TestFixture
CPPUNIT_TEST(testAIFF);
CPPUNIT_TEST(testAIFC);
CPPUNIT_TEST(testUnsupported);
CPPUNIT_TEST(testFileResolver);
CPPUNIT_TEST_SUITE_END();
public:
@ -80,26 +95,16 @@ public:
CPPUNIT_ASSERT_EQUAL(f->tag()->year(), TagLib::uint(2080));
delete f;
f = new FileRef(newname.c_str());
CPPUNIT_ASSERT(f->isValid());
FileStream fs(newname.c_str());
f = new FileRef(&fs);
CPPUNIT_ASSERT(!f->isNull());
PropertyMap prop = f->properties();
CPPUNIT_ASSERT_EQUAL(prop["ARTIST"].front(), String("ttest artist"));
CPPUNIT_ASSERT_EQUAL(prop["TITLE" ].front(), String("ytest title"));
prop["ARTIST"].front() = "a test artist";
prop["TITLE" ].front() = "b test title";
f->setProperties(prop);
f->save();
CPPUNIT_ASSERT_EQUAL(f->tag()->artist(), String("ttest artist"));
CPPUNIT_ASSERT_EQUAL(f->tag()->title(), String("ytest title"));
CPPUNIT_ASSERT_EQUAL(f->tag()->genre(), String("uTest!"));
CPPUNIT_ASSERT_EQUAL(f->tag()->album(), String("ialbummmm"));
CPPUNIT_ASSERT_EQUAL(f->tag()->track(), TagLib::uint(7));
CPPUNIT_ASSERT_EQUAL(f->tag()->year(), TagLib::uint(2080));
delete f;
f = new FileRef(newname.c_str());
CPPUNIT_ASSERT(f->isValid());
CPPUNIT_ASSERT(!f->isNull());
prop = f->properties();
CPPUNIT_ASSERT_EQUAL(prop["ARTIST"].front(), String("a test artist"));
CPPUNIT_ASSERT_EQUAL(prop["TITLE" ].front(), String("b test title"));
delete f;
}
void testMusepack()
@ -192,10 +197,25 @@ public:
{
FileRef f1(TEST_FILE_PATH_C("no-extension"));
CPPUNIT_ASSERT(f1.isNull());
FileRef f2(TEST_FILE_PATH_C("unsupported-extension.xxx"));
CPPUNIT_ASSERT(f2.isNull());
}
void testFileResolver()
{
FileRef *f = new FileRef(TEST_FILE_PATH_C("xing.mp3"));
CPPUNIT_ASSERT(dynamic_cast<MPEG::File *>(f->file()) != NULL);
delete f;
DummyResolver resolver;
FileRef::addFileTypeResolver(&resolver);
f = new FileRef(TEST_FILE_PATH_C("xing.mp3"));
CPPUNIT_ASSERT(dynamic_cast<Ogg::Vorbis::File *>(f->file()) != NULL);
delete f;
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestFileRef);

View File

@ -38,7 +38,7 @@ class PublicFrame : public ID3v2::Frame
size_t position = 0;
return ID3v2::Frame::readStringField(data, encoding, position);
}
virtual String toString() const { return String::null; }
virtual String toString() const { return String(); }
virtual void parseFields(const ByteVector &) {}
virtual ByteVector renderFields() const { return ByteVector(); }
};

View File

@ -123,10 +123,10 @@ private:
CPPUNIT_ASSERT_EQUAL((TagLib::uchar)128, p->panningSeparation());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 0, p->pitchWheelDepth());
CPPUNIT_ASSERT_EQUAL(title, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(String(), t->artist());
CPPUNIT_ASSERT_EQUAL(String(), t->album());
CPPUNIT_ASSERT_EQUAL(comment, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(String(), t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(String("Impulse Tracker"), t->trackerName());

View File

@ -113,10 +113,10 @@ private:
CPPUNIT_ASSERT_EQUAL(31U, p->instrumentCount());
CPPUNIT_ASSERT_EQUAL((uchar)1, p->lengthInPatterns());
CPPUNIT_ASSERT_EQUAL(title, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(String(), t->artist());
CPPUNIT_ASSERT_EQUAL(String(), t->album());
CPPUNIT_ASSERT_EQUAL(comment, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(String(), t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(String("StarTrekker"), t->trackerName());

View File

@ -110,10 +110,10 @@ private:
CPPUNIT_ASSERT_EQUAL((TagLib::uchar)125, p->tempo());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 6, p->bpmSpeed());
CPPUNIT_ASSERT_EQUAL(title, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(String(), t->artist());
CPPUNIT_ASSERT_EQUAL(String(), t->album());
CPPUNIT_ASSERT_EQUAL(comment, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(String(), t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(String("ScreamTracker III"), t->trackerName());

View File

@ -75,7 +75,7 @@ public:
s.clear();
CPPUNIT_ASSERT(s.isEmpty());
CPPUNIT_ASSERT(!s.isNull());
CPPUNIT_ASSERT(!s.isNull()); // deprecated, but still worth it to check.
String unicode("José Carlos", String::UTF8);
CPPUNIT_ASSERT(strcmp(unicode.toCString(), "Jos\xe9 Carlos") == 0);

View File

@ -1,5 +1,6 @@
#include <string>
#include <stdio.h>
#include <flacfile.h>
#include <xiphcomment.h>
#include <tpropertymap.h>
#include <tdebug.h>
@ -17,6 +18,7 @@ class TestXiphComment : public CppUnit::TestFixture
CPPUNIT_TEST(testTrack);
CPPUNIT_TEST(testSetTrack);
CPPUNIT_TEST(testInvalidKeys);
CPPUNIT_TEST(testClearComment);
CPPUNIT_TEST_SUITE_END();
public:
@ -74,6 +76,22 @@ public:
CPPUNIT_ASSERT(cmt.properties().isEmpty());
}
void testClearComment()
{
ScopedFileCopy copy("no-tags", ".flac");
{
FLAC::File f(copy.fileName().c_str());
f.xiphComment()->addField("COMMENT", "Comment1");
f.save();
}
{
FLAC::File f(copy.fileName().c_str());
f.xiphComment()->setComment("");
CPPUNIT_ASSERT_EQUAL(String(""), f.xiphComment()->comment());
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestXiphComment);

View File

@ -139,13 +139,13 @@ public:
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 6, p->tempo());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort)125, p->bpmSpeed());
CPPUNIT_ASSERT_EQUAL(titleBefore, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(String::null, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(String(), t->artist());
CPPUNIT_ASSERT_EQUAL(String(), t->album());
CPPUNIT_ASSERT_EQUAL(String(), t->comment());
CPPUNIT_ASSERT_EQUAL(String(), t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(String::null, t->trackerName());
CPPUNIT_ASSERT_EQUAL(String(), t->trackerName());
}
void testWriteTagsShort()
@ -185,10 +185,10 @@ private:
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 6, p->tempo());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort)125, p->bpmSpeed());
CPPUNIT_ASSERT_EQUAL(title, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(String(), t->artist());
CPPUNIT_ASSERT_EQUAL(String(), t->album());
CPPUNIT_ASSERT_EQUAL(comment, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(String(), t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(trackerName, t->trackerName());