ASF: Return excess values from setProperties (#1464)

This commit is contained in:
Nathan Chandrasekar
2026-10-17 08:36:56 +02:00
committed by GitHub
parent 96970251ce
commit 55ceae49ba
2 changed files with 57 additions and 4 deletions
+43
View File
@@ -51,6 +51,7 @@ class TestASF : public CppUnit::TestFixture
CPPUNIT_TEST(testSavePicture);
CPPUNIT_TEST(testSaveMultiplePictures);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST(testPropertiesMultipleValues);
CPPUNIT_TEST(testPropertiesAllSupported);
CPPUNIT_TEST(testPropertiesRealFile);
CPPUNIT_TEST(testRating);
@@ -309,6 +310,48 @@ public:
CPPUNIT_ASSERT_EQUAL(StringList("3"), tags["DISCNUMBER"]);
}
void testPropertiesMultipleValues()
{
for(const auto &key : {"TITLE", "ARTIST", "COMMENT", "COPYRIGHT"}) {
ScopedFileCopy copy("silence-1", ".wma");
{
ASF::File f(copy.fileName().c_str());
PropertyMap props;
props[key] = StringList("Alice").append("Bob").append("Carol");
props["ALBUM"] = StringList("First").append("Second");
const PropertyMap ignored = f.setProperties(props);
CPPUNIT_ASSERT_EQUAL(1u, ignored.size());
CPPUNIT_ASSERT_EQUAL(StringList("Bob").append("Carol"), ignored.value(key));
CPPUNIT_ASSERT_EQUAL(StringList("Alice"), f.properties().value(key));
CPPUNIT_ASSERT_EQUAL(props.value("ALBUM"), f.properties().value("ALBUM"));
CPPUNIT_ASSERT(f.save());
}
{
ASF::File f(copy.fileName().c_str());
CPPUNIT_ASSERT_EQUAL(StringList("Alice"), f.properties().value(key));
const StringList albums = f.properties().value("ALBUM");
CPPUNIT_ASSERT_EQUAL(2u, albums.size());
CPPUNIT_ASSERT(albums.contains("First"));
CPPUNIT_ASSERT(albums.contains("Second"));
PropertyMap props;
props[key] = StringList("Solo");
CPPUNIT_ASSERT(f.setProperties(props).isEmpty());
CPPUNIT_ASSERT_EQUAL(StringList("Solo"), f.properties().value(key));
props[key].clear();
CPPUNIT_ASSERT(f.setProperties(props).isEmpty());
CPPUNIT_ASSERT(!f.properties().contains(key));
props[key] = StringList("Solo");
CPPUNIT_ASSERT(f.setProperties(props).isEmpty());
CPPUNIT_ASSERT(f.setProperties(PropertyMap()).isEmpty());
CPPUNIT_ASSERT(!f.properties().contains(key));
}
}
}
void testPropertiesAllSupported()
{
PropertyMap tags;