mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
Add more unit tests
This commit is contained in:
parent
f8d78a61f7
commit
f4b476a620
@ -1554,6 +1554,57 @@ public:
|
||||
{
|
||||
MPEG::File f(TEST_FILE_PATH_C("toc_many_children.mp3"));
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
|
||||
ID3v2::Tag *tag = f.ID3v2Tag();
|
||||
const ID3v2::FrameList &frames = tag->frameList();
|
||||
CPPUNIT_ASSERT_EQUAL(130U, frames.size());
|
||||
int i = 0;
|
||||
for(ID3v2::FrameList::ConstIterator it = frames.begin(); it != frames.end();
|
||||
++it, ++i) {
|
||||
if(i > 0) {
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("CHAP"), (*it)->frameID());
|
||||
const ID3v2::ChapterFrame *chapFrame =
|
||||
dynamic_cast<const ID3v2::ChapterFrame *>(*it);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("chapter") +
|
||||
ByteVector(String::number(i - 1).toCString()),
|
||||
chapFrame->elementID());
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(100 * i),
|
||||
chapFrame->startTime());
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(100 * i),
|
||||
chapFrame->endTime());
|
||||
const ID3v2::FrameList &embeddedFrames = chapFrame->embeddedFrameList();
|
||||
CPPUNIT_ASSERT_EQUAL(1U, embeddedFrames.size());
|
||||
const ID3v2::TextIdentificationFrame *tit2Frame =
|
||||
dynamic_cast<const ID3v2::TextIdentificationFrame *>(
|
||||
embeddedFrames.front());
|
||||
CPPUNIT_ASSERT(tit2Frame);
|
||||
CPPUNIT_ASSERT_EQUAL(String("Marker ") + String::number(i),
|
||||
tit2Frame->fieldList().front());
|
||||
}
|
||||
else {
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("CTOC"), (*it)->frameID());
|
||||
const ID3v2::TableOfContentsFrame *ctocFrame =
|
||||
dynamic_cast<const ID3v2::TableOfContentsFrame *>(*it);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("toc"), ctocFrame->elementID());
|
||||
CPPUNIT_ASSERT(!ctocFrame->isTopLevel());
|
||||
CPPUNIT_ASSERT(!ctocFrame->isOrdered());
|
||||
CPPUNIT_ASSERT_EQUAL(129U, ctocFrame->entryCount());
|
||||
const ID3v2::FrameList &embeddedFrames = ctocFrame->embeddedFrameList();
|
||||
CPPUNIT_ASSERT_EQUAL(1U, embeddedFrames.size());
|
||||
const ID3v2::TextIdentificationFrame *tit2Frame =
|
||||
dynamic_cast<const ID3v2::TextIdentificationFrame *>(
|
||||
embeddedFrames.front());
|
||||
CPPUNIT_ASSERT(tit2Frame);
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("toplevel toc"), tit2Frame->fieldList());
|
||||
}
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT(!ID3v2::ChapterFrame::findByElementID(tag, "chap2"));
|
||||
CPPUNIT_ASSERT(ID3v2::ChapterFrame::findByElementID(tag, "chapter2"));
|
||||
|
||||
CPPUNIT_ASSERT(!ID3v2::TableOfContentsFrame::findTopLevel(tag));
|
||||
CPPUNIT_ASSERT(!ID3v2::TableOfContentsFrame::findByElementID(tag, "ctoc"));
|
||||
CPPUNIT_ASSERT(ID3v2::TableOfContentsFrame::findByElementID(tag, "toc"));
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -95,6 +95,9 @@ public:
|
||||
CPPUNIT_ASSERT(unsupported.contains("ARTIST"));
|
||||
CPPUNIT_ASSERT_EQUAL(properties["ARTIST"], unsupported["ARTIST"]);
|
||||
CPPUNIT_ASSERT(!unsupported.contains("TITLE"));
|
||||
|
||||
properties = t.properties();
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("title"), properties["TITLE"]);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -151,6 +151,14 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(String("ID3v1"), f.properties()["TITLE"].front());
|
||||
f.strip(MPC::File::ID3v1);
|
||||
CPPUNIT_ASSERT(f.properties().isEmpty());
|
||||
f.save();
|
||||
}
|
||||
{
|
||||
MPC::File f(copy.fileName().c_str());
|
||||
CPPUNIT_ASSERT(!f.hasAPETag());
|
||||
CPPUNIT_ASSERT(!f.hasID3v1Tag());
|
||||
CPPUNIT_ASSERT(f.properties()["TITLE"].isEmpty());
|
||||
CPPUNIT_ASSERT(f.properties().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,19 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(String("Test Artist 2"), tag.artist());
|
||||
CPPUNIT_ASSERT_EQUAL(5U, tag.track());
|
||||
|
||||
PropertyMap props = tag.properties();
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("Test Artist 2"), props.find("ARTIST")->second);
|
||||
CPPUNIT_ASSERT(props.find("COMMENT") == props.end());
|
||||
props.replace("ARTIST", StringList("Test Artist 3"));
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("Test Artist 3"), props["ARTIST"]);
|
||||
|
||||
PropertyMap eraseMap;
|
||||
eraseMap.insert("ARTIST", StringList());
|
||||
eraseMap.insert("ALBUM", StringList());
|
||||
eraseMap.insert("TITLE", StringList());
|
||||
props.erase(eraseMap);
|
||||
CPPUNIT_ASSERT_EQUAL(String("DATE=2015\nTRACKNUMBER=5\n"), props.toString());
|
||||
|
||||
tag.setProperties(PropertyMap());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), tag.title());
|
||||
|
@ -86,11 +86,21 @@ public:
|
||||
}
|
||||
{
|
||||
TrueAudio::File f(copy.fileName().c_str());
|
||||
CPPUNIT_ASSERT(f.hasID3v1Tag());
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
CPPUNIT_ASSERT_EQUAL(String("ID3v2"), f.properties()["TITLE"].front());
|
||||
f.strip(TrueAudio::File::ID3v2);
|
||||
CPPUNIT_ASSERT_EQUAL(String("ID3v1"), f.properties()["TITLE"].front());
|
||||
f.strip(TrueAudio::File::ID3v1);
|
||||
CPPUNIT_ASSERT(f.properties().isEmpty());
|
||||
f.save();
|
||||
}
|
||||
{
|
||||
TrueAudio::File f(copy.fileName().c_str());
|
||||
CPPUNIT_ASSERT(!f.hasID3v1Tag());
|
||||
CPPUNIT_ASSERT(!f.hasID3v2Tag());
|
||||
CPPUNIT_ASSERT(f.properties()["TITLE"].isEmpty());
|
||||
CPPUNIT_ASSERT(f.properties().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user