mirror of
https://github.com/taglib/taglib.git
synced 2025-06-03 09:08:09 -04:00
Fix a bug that Tag::setProperties() clears the date instead of the track number.
This commit is contained in:
parent
8fccaf30d2
commit
68c0b0591b
@ -137,7 +137,7 @@ PropertyMap Tag::setProperties(const PropertyMap &origProps)
|
||||
setTrack(0);
|
||||
}
|
||||
else
|
||||
setYear(0);
|
||||
setTrack(0);
|
||||
|
||||
// for each tag that has been set above, remove the first entry in the corresponding
|
||||
// value list. The others will be returned as unsupported by this format.
|
||||
|
@ -1,25 +1,32 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tag.h>
|
||||
#include <id3v1tag.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
|
||||
using namespace TagLib;
|
||||
|
||||
class TestPropertyMap : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestPropertyMap);
|
||||
CPPUNIT_TEST(testInvalidKeys);
|
||||
CPPUNIT_TEST(testGetSet);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
void testInvalidKeys()
|
||||
{
|
||||
TagLib::PropertyMap map1;
|
||||
PropertyMap map1;
|
||||
CPPUNIT_ASSERT(map1.isEmpty());
|
||||
map1[L"\x00c4\x00d6\x00dc"].append("test");
|
||||
CPPUNIT_ASSERT_EQUAL(map1.size(), 1u);
|
||||
|
||||
TagLib::PropertyMap map2;
|
||||
PropertyMap map2;
|
||||
map2[L"\x00c4\x00d6\x00dc"].append("test");
|
||||
CPPUNIT_ASSERT(map1 == map2);
|
||||
CPPUNIT_ASSERT(map1.contains(map2));
|
||||
|
||||
map2["ARTIST"] = TagLib::String("Test Artist");
|
||||
map2["ARTIST"] = String("Test Artist");
|
||||
CPPUNIT_ASSERT(map1 != map2);
|
||||
CPPUNIT_ASSERT(map2.contains(map1));
|
||||
|
||||
@ -27,6 +34,43 @@ public:
|
||||
CPPUNIT_ASSERT(!map2.contains(map1));
|
||||
|
||||
}
|
||||
|
||||
void testGetSet()
|
||||
{
|
||||
ID3v1::Tag tag;
|
||||
|
||||
tag.setTitle("Test Title");
|
||||
tag.setArtist("Test Artist");
|
||||
tag.setAlbum("Test Album");
|
||||
tag.setYear(2015);
|
||||
tag.setTrack(10);
|
||||
|
||||
{
|
||||
PropertyMap prop = tag.properties();
|
||||
CPPUNIT_ASSERT_EQUAL(String("Test Title"), prop["TITLE" ].front());
|
||||
CPPUNIT_ASSERT_EQUAL(String("Test Artist"), prop["ARTIST" ].front());
|
||||
CPPUNIT_ASSERT_EQUAL(String("Test Album"), prop["ALBUM" ].front());
|
||||
CPPUNIT_ASSERT_EQUAL(String("2015"), prop["DATE" ].front());
|
||||
CPPUNIT_ASSERT_EQUAL(String("10"), prop["TRACKNUMBER"].front());
|
||||
|
||||
prop["TITLE" ].front() = "Test Title 2";
|
||||
prop["ARTIST" ].front() = "Test Artist 2";
|
||||
prop["TRACKNUMBER"].front() = "5";
|
||||
|
||||
tag.setProperties(prop);
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(String("Test Title 2"), tag.title());
|
||||
CPPUNIT_ASSERT_EQUAL(String("Test Artist 2"), tag.artist());
|
||||
CPPUNIT_ASSERT_EQUAL(5U, tag.track());
|
||||
|
||||
tag.setProperties(PropertyMap());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), tag.title());
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), tag.artist());
|
||||
CPPUNIT_ASSERT_EQUAL(0U, tag.track());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestPropertyMap);
|
||||
|
Loading…
x
Reference in New Issue
Block a user