mirror of
https://github.com/taglib/taglib.git
synced 2025-07-19 05:24:25 -04:00
Merge remote-tracking branch 'supermihi/master'
This commit is contained in:
@ -35,6 +35,7 @@ SET(test_runner_SRCS
|
||||
test_bytevectorlist.cpp
|
||||
test_bytevectorstream.cpp
|
||||
test_string.cpp
|
||||
test_propertymap.cpp
|
||||
test_fileref.cpp
|
||||
test_id3v1.cpp
|
||||
test_id3v2.cpp
|
||||
|
@ -19,6 +19,7 @@ class TestAPETag : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testIsEmpty2);
|
||||
CPPUNIT_TEST(testPropertyInterface1);
|
||||
CPPUNIT_TEST(testPropertyInterface2);
|
||||
CPPUNIT_TEST(testInvalidKeys);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -76,12 +77,27 @@ public:
|
||||
APE::Item item3 = APE::Item("TRACKNUMBER", "29");
|
||||
tag.setItem("TRACKNUMBER", item3);
|
||||
properties = tag.properties();
|
||||
CPPUNIT_ASSERT_EQUAL(2u, properties["TRACKNUMBER"].size());
|
||||
CPPUNIT_ASSERT_EQUAL(uint(2), properties["TRACKNUMBER"].size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("17"), properties["TRACKNUMBER"][0]);
|
||||
CPPUNIT_ASSERT_EQUAL(String("29"), properties["TRACKNUMBER"][1]);
|
||||
|
||||
}
|
||||
|
||||
void testInvalidKeys()
|
||||
{
|
||||
PropertyMap properties;
|
||||
properties["A"] = String("invalid key: one character");
|
||||
properties["MP+"] = String("invalid key: forbidden string");
|
||||
properties["A B~C"] = String("valid key: space and tilde");
|
||||
properties["ARTIST"] = String("valid key: normal one");
|
||||
|
||||
APE::Tag tag;
|
||||
PropertyMap unsuccessful = tag.setProperties(properties);
|
||||
CPPUNIT_ASSERT_EQUAL(uint(2), unsuccessful.size());
|
||||
CPPUNIT_ASSERT(unsuccessful.contains("A"));
|
||||
CPPUNIT_ASSERT(unsuccessful.contains("MP+"));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestAPETag);
|
||||
|
@ -72,6 +72,7 @@ class TestID3v2 : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testW000);
|
||||
CPPUNIT_TEST(testPropertyInterface);
|
||||
CPPUNIT_TEST(testPropertyInterface2);
|
||||
CPPUNIT_TEST(testDeleteFrame);
|
||||
CPPUNIT_TEST(testSaveAndStripID3v1ShouldNotAddFrameFromID3v1ToId3v2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
@ -640,6 +641,21 @@ public:
|
||||
CPPUNIT_ASSERT(tag.frameList("TIPL").isEmpty());
|
||||
}
|
||||
|
||||
void testDeleteFrame()
|
||||
{
|
||||
ScopedFileCopy copy("rare_frames", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
MPEG::File f(newname.c_str());
|
||||
ID3v2::Tag *t = f.ID3v2Tag();
|
||||
ID3v2::Frame *frame = t->frameList("TCON")[0];
|
||||
CPPUNIT_ASSERT_EQUAL(1u, t->frameList("TCON").size());
|
||||
t->removeFrame(frame, true);
|
||||
f.save(MPEG::File::ID3v2);
|
||||
|
||||
MPEG::File f2(newname.c_str());
|
||||
t = f2.ID3v2Tag();
|
||||
CPPUNIT_ASSERT(t->frameList("TCON").isEmpty());
|
||||
}
|
||||
void testSaveAndStripID3v1ShouldNotAddFrameFromID3v1ToId3v2()
|
||||
{
|
||||
ScopedFileCopy copy("xing", ".mp3");
|
||||
|
32
tests/test_propertymap.cpp
Normal file
32
tests/test_propertymap.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <tpropertymap.h>
|
||||
class TestPropertyMap : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestPropertyMap);
|
||||
CPPUNIT_TEST(testInvalidKeys);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
void testInvalidKeys()
|
||||
{
|
||||
TagLib::PropertyMap map1;
|
||||
CPPUNIT_ASSERT(map1.isEmpty());
|
||||
map1["ÄÖÜ"].append("test");
|
||||
CPPUNIT_ASSERT_EQUAL(map1.size(), 1u);
|
||||
|
||||
TagLib::PropertyMap map2;
|
||||
map2["ÄÖÜ"].append("test");
|
||||
CPPUNIT_ASSERT(map1 == map2);
|
||||
CPPUNIT_ASSERT(map1.contains(map2));
|
||||
|
||||
map2["ARTIST"] = TagLib::String("Test Artist");
|
||||
CPPUNIT_ASSERT(map1 != map2);
|
||||
CPPUNIT_ASSERT(map2.contains(map1));
|
||||
|
||||
map2["ÄÖÜ"].append("test 2");
|
||||
CPPUNIT_ASSERT(!map2.contains(map1));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestPropertyMap);
|
@ -2,6 +2,7 @@
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <xiphcomment.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tdebug.h>
|
||||
#include "utils.h"
|
||||
|
||||
@ -15,6 +16,7 @@ class TestXiphComment : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testSetYear);
|
||||
CPPUNIT_TEST(testTrack);
|
||||
CPPUNIT_TEST(testSetTrack);
|
||||
CPPUNIT_TEST(testInvalidKeys);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -59,6 +61,19 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(String("3"), cmt.fieldListMap()["TRACKNUMBER"].front());
|
||||
}
|
||||
|
||||
void testInvalidKeys()
|
||||
{
|
||||
PropertyMap map;
|
||||
map[""] = String("invalid key: empty string");
|
||||
map["A=B"] = String("invalid key: contains '='");
|
||||
map["A~B"] = String("invalid key: contains '~'");
|
||||
|
||||
Ogg::XiphComment cmt;
|
||||
PropertyMap unsuccessful = cmt.setProperties(map);
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), unsuccessful.size());
|
||||
CPPUNIT_ASSERT(cmt.properties().isEmpty());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestXiphComment);
|
||||
|
Reference in New Issue
Block a user