fixed bugs preventing tests from running

This commit is contained in:
Michael Helmling 2012-02-19 15:13:31 +01:00
parent 6c054af3ed
commit 23d303a896
6 changed files with 24 additions and 15 deletions

View File

@ -114,9 +114,9 @@ PropertyMap CommentsFrame::asProperties() const
{
String key = PropertyMap::prepareKey(description());
PropertyMap map;
if(key.isEmpty())
key = "COMMENT";
if(key.isNull())
if(key.isEmpty() || key == "COMMENT")
map.insert("COMMENT", text());
else if(key.isNull())
map.unsupportedData().append(L"COMM/" + description());
else
map.insert("COMMENT:" + key, text());

View File

@ -156,12 +156,10 @@ void UserUrlLinkFrame::setDescription(const String &s)
PropertyMap UserUrlLinkFrame::asProperties() const
{
PropertyMap map;
String key;
if(description().isEmpty())
key = "URL";
else
key = PropertyMap::prepareKey(description());
if(key.isNull())
String key = PropertyMap::prepareKey(description());
if(key.isEmpty() || key.upper() == "URL")
map.insert("URL", url());
else if(key.isNull())
map.unsupportedData().append(L"WXXX/" + description());
else
map.insert("URL:" + key, url());

View File

@ -337,10 +337,8 @@ void ID3v2::Tag::removeFrames(const ByteVector &id)
PropertyMap ID3v2::Tag::properties() const
{
PropertyMap properties;
for(FrameList::ConstIterator it = frameList().begin(); it != frameList().end(); ++it) {
PropertyMap props = (*it)->asProperties();
debug(props);
properties.merge(props);
}
return properties;

View File

@ -161,6 +161,14 @@ bool PropertyMap::operator!=(const PropertyMap &other) const
return !(*this == other);
}
String PropertyMap::toString() const
{
String ret = "";
for(ConstIterator it = begin(); it != end(); ++it)
ret += it->first+"="+it->second.toString(", ") + "\n";
return ret;
}
void PropertyMap::removeEmpty()
{
StringList emptyKeys;

View File

@ -166,6 +166,8 @@ namespace TagLib {
*/
void removeEmpty();
String toString() const;
/*!
* Converts \a proposed into another String suitable to be used as
* a key, or returns String::null if this is not possible.

View File

@ -561,12 +561,15 @@ public:
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"].front());
CPPUNIT_ASSERT_EQUAL(String("http://a.user.url"), dict["URL:USERURL"][0]);
CPPUNIT_ASSERT_EQUAL(String("http://a.user.url/with/empty/description"), dict["URL"][0]);
CPPUNIT_ASSERT_EQUAL(String("http://a.user.url"), dict["URL:USERURL"].front());
CPPUNIT_ASSERT_EQUAL(String("http://a.user.url/with/empty/description"), dict["URL"].front());
debug(dict.toString());
CPPUNIT_ASSERT_EQUAL(String("A COMMENT"), dict["COMMENT"].front());
debug("565");
CPPUNIT_ASSERT_EQUAL(String("A COMMENT"), dict["COMMENT"][0]);
CPPUNIT_ASSERT_EQUAL(1u, dict.unsupportedData().size());
CPPUNIT_ASSERT_EQUAL(String("UFID"), dict.unsupportedData().front());
}