mirror of
https://github.com/taglib/taglib.git
synced 2025-07-19 05:24:25 -04:00
Added tests and information about ignored id3 frames.
The ID3v2::toDict() function now has an optional StringList* argument which will contain information about frames that could not be converted to the dict interface. There are some dict tests for APE and FLAC now, and the ID3v2 test was enlarged.
This commit is contained in:
@ -15,6 +15,7 @@ class TestAPETag : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST_SUITE(TestAPETag);
|
||||
CPPUNIT_TEST(testIsEmpty);
|
||||
CPPUNIT_TEST(testIsEmpty2);
|
||||
CPPUNIT_TEST(testDict);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -35,6 +36,21 @@ public:
|
||||
CPPUNIT_ASSERT(!tag.isEmpty());
|
||||
}
|
||||
|
||||
void testDict()
|
||||
{
|
||||
APE::Tag tag;
|
||||
TagDict dict = tag.toDict();
|
||||
CPPUNIT_ASSERT(dict.isEmpty());
|
||||
dict["ARTIST"] = String("artist 1");
|
||||
dict["ARTIST"].append("artist 2");
|
||||
dict["TRACKNUMBER"].append("17");
|
||||
tag.fromDict(dict);
|
||||
CPPUNIT_ASSERT_EQUAL(String("17"), tag.itemListMap()["TRACK"].values()[0]);
|
||||
CPPUNIT_ASSERT_EQUAL(2u, tag.itemListMap()["ARTIST"].values().size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("artist 1"), tag.artist());
|
||||
CPPUNIT_ASSERT_EQUAL(17u, tag.track());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestAPETag);
|
||||
|
@ -22,6 +22,7 @@ class TestFLAC : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testRemoveAllPictures);
|
||||
CPPUNIT_TEST(testRepeatedSave);
|
||||
CPPUNIT_TEST(testSaveMultipleValues);
|
||||
CPPUNIT_TEST(testDict);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -208,6 +209,27 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(String("artist 2"), m["ARTIST"][1]);
|
||||
}
|
||||
|
||||
void testDict()
|
||||
{
|
||||
// test unicode & multiple values with dict interface
|
||||
ScopedFileCopy copy("silence-44-s", ".flac");
|
||||
string newname = copy.fileName();
|
||||
|
||||
FLAC::File *f = new FLAC::File(newname.c_str());
|
||||
TagDict dict;
|
||||
dict["ARTIST"].append("artøst 1");
|
||||
dict["ARTIST"].append("artöst 2");
|
||||
f->fromDict(dict);
|
||||
f->save();
|
||||
delete f;
|
||||
|
||||
f = new FLAC::File(newname.c_str());
|
||||
dict = f->toDict();
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), dict["ARTIST"].size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("artøst 1"), dict["ARTIST"][0]);
|
||||
CPPUNIT_ASSERT_EQUAL(String("artöst 2"), dict["ARTIST"][1]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestFLAC);
|
||||
|
@ -553,20 +553,22 @@ public:
|
||||
ScopedFileCopy copy("rare_frames", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
MPEG::File f(newname.c_str());
|
||||
TagDict dict = f.ID3v2Tag(false)->toDict();
|
||||
StringList ignored;
|
||||
TagDict dict = f.ID3v2Tag(false)->toDict(&ignored);
|
||||
CPPUNIT_ASSERT_EQUAL(uint(6), dict.size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("userTextData1"), dict["USERTEXTDESCRIPTION1"][0]);
|
||||
CPPUNIT_ASSERT_EQUAL(String("userTextData2"), dict["USERTEXTDESCRIPTION1"][1]);
|
||||
CPPUNIT_ASSERT_EQUAL(String("userTextData1"), dict["USERTEXTDESCRIPTION2"][0]);
|
||||
CPPUNIT_ASSERT_EQUAL(String("userTextData2"), dict["USERTEXTDESCRIPTION2"][1]);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(String("Pop"), dict["GENRE"][0]);
|
||||
CPPUNIT_ASSERT_EQUAL(String("Pop"), dict["GENRE"][0]);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(String("http://a.user.url"), dict["USERURL"][0]);
|
||||
CPPUNIT_ASSERT_EQUAL(String("http://a.user.url/with/empty/description"), dict["URL"][0]);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(String("A COMMENT"), dict["COMMENT"][0]);
|
||||
CPPUNIT_ASSERT_EQUAL(String("UFID frame is not supported"), ignored[0]);
|
||||
CPPUNIT_ASSERT_EQUAL(1u, ignored.size());
|
||||
}
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user