mirror of
				https://github.com/taglib/taglib.git
				synced 2025-11-04 08:45:10 -05:00 
			
		
		
		
	Fix a bug that Tag::setProperties() clears the date instead of the track number.
This commit is contained in:
		@ -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);
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user