diff options
author | Urs Fleisch <ufleisch@users.sourceforge.net> | 2021-01-17 14:47:33 +0100 |
---|---|---|
committer | Urs Fleisch <ufleisch@users.sourceforge.net> | 2021-01-18 20:31:52 +0100 |
commit | f4b476a620a3d04534b502b3776a446091d3c87e (patch) | |
tree | adbd00006378d125f09a3011e6535be0756bf015 /tests | |
parent | f8d78a61f7b1a1aaf094009d7c32ef9eeb461fad (diff) |
Add more unit tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_id3v2.cpp | 51 | ||||
-rw-r--r-- | tests/test_mod.cpp | 3 | ||||
-rw-r--r-- | tests/test_mpc.cpp | 8 | ||||
-rw-r--r-- | tests/test_propertymap.cpp | 13 | ||||
-rw-r--r-- | tests/test_trueaudio.cpp | 10 |
5 files changed, 85 insertions, 0 deletions
diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index f03c82cc..521f460a 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -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")); } }; diff --git a/tests/test_mod.cpp b/tests/test_mod.cpp index e1c07b7f..55fd7438 100644 --- a/tests/test_mod.cpp +++ b/tests/test_mod.cpp @@ -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: diff --git a/tests/test_mpc.cpp b/tests/test_mpc.cpp index 059e521f..25f75944 100644 --- a/tests/test_mpc.cpp +++ b/tests/test_mpc.cpp @@ -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()); } } diff --git a/tests/test_propertymap.cpp b/tests/test_propertymap.cpp index 855ff67e..2125fb57 100644 --- a/tests/test_propertymap.cpp +++ b/tests/test_propertymap.cpp @@ -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()); diff --git a/tests/test_trueaudio.cpp b/tests/test_trueaudio.cpp index 2a040367..d8e6fbca 100644 --- a/tests/test_trueaudio.cpp +++ b/tests/test_trueaudio.cpp @@ -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()); } } |