]> granicus.if.org Git - taglib/commitdiff
Fix a bug that Tag::setProperties() clears the date instead of the track number.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Fri, 20 Mar 2015 04:33:13 +0000 (13:33 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Fri, 20 Mar 2015 04:33:13 +0000 (13:33 +0900)
taglib/tag.cpp
tests/test_propertymap.cpp

index 98c2304395846f6f75c69d2bbad1d242c4aa818b..eb8fab7a32b7d4fb8c5c56a9421327850a026f83 100644 (file)
@@ -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.
index 0ca7b72315556f551ede9375c639c579e22b62de..49d856a01ea6c73d123f1bbd6981cd8bc8b3a29f 100644 (file)
@@ -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);