Merge remote-tracking branch 'official/master'

This commit is contained in:
Michael Helmling
2012-12-10 19:55:29 +01:00
112 changed files with 3012 additions and 258 deletions

View File

@@ -16,6 +16,8 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/vorbis
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/flac
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/speex
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/opus
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/flac
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/wavpack
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mod
@@ -60,8 +62,11 @@ SET(test_runner_SRCS
test_it.cpp
test_xm.cpp
test_mpc.cpp
test_opus.cpp
)
INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
ADD_EXECUTABLE(test_runner ${test_runner_SRCS})
TARGET_LINK_LIBRARIES(test_runner tag ${CPPUNIT_LIBRARIES})

Binary file not shown.

BIN
tests/data/w000.mp3 Normal file

Binary file not shown.

View File

@@ -1,4 +1,3 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
@@ -7,6 +6,7 @@
#include <tpropertymap.h>
#include <apetag.h>
#include <tdebug.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
@@ -77,7 +77,7 @@ public:
APE::Item item3 = APE::Item("TRACKNUMBER", "29");
tag.setItem("TRACKNUMBER", item3);
properties = tag.properties();
CPPUNIT_ASSERT_EQUAL(uint(2), properties["TRACKNUMBER"].size());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), properties["TRACKNUMBER"].size());
CPPUNIT_ASSERT_EQUAL(String("17"), properties["TRACKNUMBER"][0]);
CPPUNIT_ASSERT_EQUAL(String("29"), properties["TRACKNUMBER"][1]);
@@ -93,7 +93,7 @@ public:
APE::Tag tag;
PropertyMap unsuccessful = tag.setProperties(properties);
CPPUNIT_ASSERT_EQUAL(uint(2), unsuccessful.size());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), unsuccessful.size());
CPPUNIT_ASSERT(unsuccessful.contains("A"));
CPPUNIT_ASSERT(unsuccessful.contains("MP+"));
}

View File

@@ -1,10 +1,11 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <tpropertymap.h>
#include <asffile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
@@ -13,7 +14,7 @@ using namespace TagLib;
class TestASF : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestASF);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST(testAudioProperties);
CPPUNIT_TEST(testRead);
CPPUNIT_TEST(testSaveMultipleValues);
CPPUNIT_TEST(testSaveStream);
@@ -22,11 +23,12 @@ class TestASF : public CppUnit::TestFixture
CPPUNIT_TEST(testSaveLargeValue);
CPPUNIT_TEST(testSavePicture);
CPPUNIT_TEST(testSaveMultiplePictures);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST_SUITE_END();
public:
void testProperties()
void testAudioProperties()
{
ASF::File f(TEST_FILE_PATH_C("silence-1.wma"));
CPPUNIT_ASSERT_EQUAL(4, f.audioProperties()->length());
@@ -215,6 +217,39 @@ public:
delete f;
}
void testProperties()
{
ASF::File f(TEST_FILE_PATH_C("silence-1.wma"));
PropertyMap tags = f.properties();
tags["TRACKNUMBER"] = StringList("2");
tags["DISCNUMBER"] = StringList("3");
tags["BPM"] = StringList("123");
tags["ARTIST"] = StringList("Foo Bar");
f.setProperties(tags);
tags = f.properties();
CPPUNIT_ASSERT_EQUAL(String("Foo Bar"), f.tag()->artist());
CPPUNIT_ASSERT_EQUAL(StringList("Foo Bar"), tags["ARTIST"]);
CPPUNIT_ASSERT(f.tag()->attributeListMap().contains("WM/BeatsPerMinute"));
CPPUNIT_ASSERT_EQUAL(1u, f.tag()->attributeListMap()["WM/BeatsPerMinute"].size());
CPPUNIT_ASSERT_EQUAL(String("123"), f.tag()->attributeListMap()["WM/BeatsPerMinute"].front().toString());
CPPUNIT_ASSERT_EQUAL(StringList("123"), tags["BPM"]);
CPPUNIT_ASSERT(f.tag()->attributeListMap().contains("WM/TrackNumber"));
CPPUNIT_ASSERT_EQUAL(1u, f.tag()->attributeListMap()["WM/TrackNumber"].size());
CPPUNIT_ASSERT_EQUAL(String("2"), f.tag()->attributeListMap()["WM/TrackNumber"].front().toString());
CPPUNIT_ASSERT_EQUAL(StringList("2"), tags["TRACKNUMBER"]);
CPPUNIT_ASSERT(f.tag()->attributeListMap().contains("WM/PartOfSet"));
CPPUNIT_ASSERT_EQUAL(1u, f.tag()->attributeListMap()["WM/PartOfSet"].size());
CPPUNIT_ASSERT_EQUAL(String("3"), f.tag()->attributeListMap()["WM/PartOfSet"].front().toString());
CPPUNIT_ASSERT_EQUAL(StringList("3"), tags["DISCNUMBER"]);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestASF);

View File

@@ -22,9 +22,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <tbytevector.h>
#include <tbytevectorlist.h>
#include <cppunit/extensions/HelperMacros.h>
using namespace std;
using namespace TagLib;

View File

@@ -1,6 +1,6 @@
#include <cppunit/extensions/HelperMacros.h>
#include <tbytevector.h>
#include <tbytevectorlist.h>
#include <cppunit/extensions/HelperMacros.h>
using namespace std;
using namespace TagLib;

View File

@@ -1,5 +1,5 @@
#include <cppunit/extensions/HelperMacros.h>
#include <tbytevectorstream.h>
#include <cppunit/extensions/HelperMacros.h>
using namespace std;
using namespace TagLib;

View File

@@ -1,10 +1,10 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <fileref.h>
#include <oggflacfile.h>
#include <vorbisfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -29,6 +29,7 @@ class TestFileRef : public CppUnit::TestFixture
CPPUNIT_TEST(testMP4_3);
CPPUNIT_TEST(testTrueAudio);
CPPUNIT_TEST(testAPE);
CPPUNIT_TEST(testWav);
CPPUNIT_TEST_SUITE_END();
public:
@@ -127,6 +128,11 @@ public:
fileRefSave("no-tags", ".3g2");
}
void testWav()
{
fileRefSave("empty", ".wav");
}
void testOGA_FLAC()
{
FileRef *f = new FileRef(TEST_FILE_PATH_C("empty_flac.oga"));
@@ -143,7 +149,7 @@ public:
void testAPE()
{
fileRefSave("mac-399.ape", ".ape");
fileRefSave("mac-399", ".ape");
}
};

View File

@@ -1,4 +1,3 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
@@ -7,6 +6,7 @@
#include <tpropertymap.h>
#include <flacfile.h>
#include <xiphcomment.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;

View File

@@ -1,4 +1,3 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
@@ -6,6 +5,7 @@
#include <tbytevectorlist.h>
#include <flacfile.h>
#include <flacmetadatablock.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;

View File

@@ -1,10 +1,10 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <flacunknownmetadatablock.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;

View File

@@ -1,7 +1,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <id3v1tag.h>
#include <cppunit/extensions/HelperMacros.h>
using namespace std;
using namespace TagLib;

View File

@@ -1,4 +1,3 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
// so evil :(
@@ -15,8 +14,10 @@
#include <relativevolumeframe.h>
#include <popularimeterframe.h>
#include <urllinkframe.h>
#include <ownershipframe.h>
#include <tdebug.h>
#include <tpropertymap.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
@@ -61,6 +62,8 @@ class TestID3v2 : public CppUnit::TestFixture
CPPUNIT_TEST(testRenderUrlLinkFrame);
CPPUNIT_TEST(testParseUserUrlLinkFrame);
CPPUNIT_TEST(testRenderUserUrlLinkFrame);
CPPUNIT_TEST(testParseOwnershipFrame);
CPPUNIT_TEST(testRenderOwnershipFrame);
CPPUNIT_TEST(testSaveUTF16Comment);
CPPUNIT_TEST(testUpdateGenre23_1);
CPPUNIT_TEST(testUpdateGenre23_2);
@@ -69,6 +72,7 @@ class TestID3v2 : public CppUnit::TestFixture
CPPUNIT_TEST(testDowngradeTo23);
// CPPUNIT_TEST(testUpdateFullDate22); TODO TYE+TDA should be upgraded to TDRC together
CPPUNIT_TEST(testCompressedFrameWithBrokenLength);
CPPUNIT_TEST(testW000);
CPPUNIT_TEST(testPropertyInterface);
CPPUNIT_TEST(testPropertyInterface2);
CPPUNIT_TEST(testDeleteFrame);
@@ -385,6 +389,38 @@ public:
"http://example.com", 33), // URL
f.render());
}
void testParseOwnershipFrame()
{
ID3v2::OwnershipFrame f(
ByteVector("OWNE" // Frame ID
"\x00\x00\x00\x19" // Frame size
"\x00\x00" // Frame flags
"\x00" // Text encoding
"GBP1.99\x00" // Price paid
"20120905" // Date of purchase
"Beatport", 35)); // Seller
CPPUNIT_ASSERT_EQUAL(String("GBP1.99"), f.pricePaid());
CPPUNIT_ASSERT_EQUAL(String("20120905"), f.datePurchased());
CPPUNIT_ASSERT_EQUAL(String("Beatport"), f.seller());
}
void testRenderOwnershipFrame()
{
ID3v2::OwnershipFrame f;
f.setPricePaid("GBP1.99");
f.setDatePurchased("20120905");
f.setSeller("Beatport");
CPPUNIT_ASSERT_EQUAL(
ByteVector("OWNE" // Frame ID
"\x00\x00\x00\x19" // Frame size
"\x00\x00" // Frame flags
"\x00" // Text encoding
"GBP1.99\x00" // Price paid
"20120905" // Date of purchase
"Beatport", 35), // URL
f.render());
}
void testItunes24FrameSize()
{
@@ -552,6 +588,16 @@ public:
CPPUNIT_ASSERT_EQUAL(String(""), frame->description());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(86414), frame->picture().size());
}
void testW000()
{
MPEG::File f(TEST_FILE_PATH_C("w000.mp3"), false);
CPPUNIT_ASSERT(f.ID3v2Tag()->frameListMap().contains("W000"));
ID3v2::UrlLinkFrame *frame =
dynamic_cast<TagLib::ID3v2::UrlLinkFrame*>(f.ID3v2Tag()->frameListMap()["W000"].front());
CPPUNIT_ASSERT(frame);
CPPUNIT_ASSERT_EQUAL(String("lukas.lalinsky@example.com____"), frame->url());
}
void testPropertyInterface()
{
@@ -578,7 +624,7 @@ public:
CPPUNIT_ASSERT_EQUAL(String("A COMMENT"), dict["COMMENT"].front());
CPPUNIT_ASSERT_EQUAL(1u, dict.unsupportedData().size());
CPPUNIT_ASSERT_EQUAL(String("UFID"), dict.unsupportedData().front());
CPPUNIT_ASSERT_EQUAL(String("UFID/supermihi@web.de"), dict.unsupportedData().front());
}
void testPropertyInterface2()
@@ -611,11 +657,23 @@ public:
frame5->setText(tmclData);
tag.addFrame(frame5);
ID3v2::UniqueFileIdentifierFrame *frame6 = new ID3v2::UniqueFileIdentifierFrame("http://musicbrainz.org", "152454b9-19ba-49f3-9fc9-8fc26545cf41");
tag.addFrame(frame6);
ID3v2::UniqueFileIdentifierFrame *frame7 = new ID3v2::UniqueFileIdentifierFrame("http://example.com", "123");
tag.addFrame(frame7);
ID3v2::UserTextIdentificationFrame *frame8 = new ID3v2::UserTextIdentificationFrame();
frame8->setDescription("MusicBrainz Album Id");
frame8->setText("95c454a5-d7e0-4d8f-9900-db04aca98ab3");
tag.addFrame(frame8);
PropertyMap properties = tag.properties();
CPPUNIT_ASSERT_EQUAL(2u, properties.unsupportedData().size());
CPPUNIT_ASSERT_EQUAL(3u, properties.unsupportedData().size());
CPPUNIT_ASSERT(properties.unsupportedData().contains("TIPL"));
CPPUNIT_ASSERT(properties.unsupportedData().contains("APIC"));
CPPUNIT_ASSERT(properties.unsupportedData().contains("UFID/http://example.com"));
CPPUNIT_ASSERT(properties.contains("PERFORMER:VIOLIN"));
CPPUNIT_ASSERT(properties.contains("PERFORMER:PIANO"));
@@ -625,9 +683,17 @@ public:
CPPUNIT_ASSERT(properties.contains("LYRICS"));
CPPUNIT_ASSERT(properties.contains("LYRICS:TEST"));
CPPUNIT_ASSERT(properties.contains("MUSICBRAINZ_TRACKID"));
CPPUNIT_ASSERT_EQUAL(String("152454b9-19ba-49f3-9fc9-8fc26545cf41"), properties["MUSICBRAINZ_TRACKID"].front());
CPPUNIT_ASSERT(properties.contains("MUSICBRAINZ_ALBUMID"));
CPPUNIT_ASSERT_EQUAL(String("95c454a5-d7e0-4d8f-9900-db04aca98ab3"), properties["MUSICBRAINZ_ALBUMID"].front());
tag.removeUnsupportedProperties(properties.unsupportedData());
CPPUNIT_ASSERT(tag.frameList("APIC").isEmpty());
CPPUNIT_ASSERT(tag.frameList("TIPL").isEmpty());
CPPUNIT_ASSERT_EQUAL((ID3v2::UniqueFileIdentifierFrame *)0, ID3v2::UniqueFileIdentifierFrame::findByOwner(&tag, "http://example.com"));
CPPUNIT_ASSERT_EQUAL(frame6, ID3v2::UniqueFileIdentifierFrame::findByOwner(&tag, "http://musicbrainz.org"));
}
void testDeleteFrame()
@@ -640,29 +706,30 @@ public:
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");
string newname = copy.fileName();
{
MPEG::File foo(newname.c_str());
foo.tag()->setArtist("Artist");
foo.save(MPEG::File::ID3v1 | MPEG::File::ID3v2);
}
{
MPEG::File bar(newname.c_str());
bar.ID3v2Tag()->removeFrames("TPE1");
// Should strip ID3v1 here and not add old values to ID3v2 again
bar.save(MPEG::File::ID3v2, true);
}
MPEG::File f(newname.c_str());
CPPUNIT_ASSERT(!f.ID3v2Tag()->frameListMap().contains("TPE1"));
}

45
tests/test_info.cpp Normal file
View File

@@ -0,0 +1,45 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <infotag.h>
#include <tpropertymap.h>
#include <tdebug.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestInfoTag : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestInfoTag);
CPPUNIT_TEST(testTitle);
CPPUNIT_TEST(testNumericFields);
CPPUNIT_TEST_SUITE_END();
public:
void testTitle()
{
RIFF::Info::Tag tag;
CPPUNIT_ASSERT_EQUAL(String(""), tag.title());
tag.setTitle("Test title 1");
CPPUNIT_ASSERT_EQUAL(String("Test title 1"), tag.title());
}
void testNumericFields()
{
RIFF::Info::Tag tag;
CPPUNIT_ASSERT_EQUAL((uint)0, tag.track());
tag.setTrack(1234);
CPPUNIT_ASSERT_EQUAL((uint)1234, tag.track());
CPPUNIT_ASSERT_EQUAL(String("1234"), tag.fieldText("IPRT"));
CPPUNIT_ASSERT_EQUAL((uint)0, tag.year());
tag.setYear(1234);
CPPUNIT_ASSERT_EQUAL((uint)1234, tag.year());
CPPUNIT_ASSERT_EQUAL(String("1234"), tag.fieldText("ICRD"));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestInfoTag);

View File

@@ -19,9 +19,9 @@
* MA 02110-1301 USA *
***************************************************************************/
#include <cppunit/extensions/HelperMacros.h>
#include <itfile.h>
#include <tstringlist.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;

View File

@@ -19,9 +19,9 @@
* MA 02110-1301 USA *
***************************************************************************/
#include <cppunit/extensions/HelperMacros.h>
#include <modfile.h>
#include <tpropertymap.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;

View File

@@ -1,11 +1,12 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <mp4tag.h>
#include <tbytevectorlist.h>
#include <tpropertymap.h>
#include <mp4atom.h>
#include <mp4file.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
@@ -25,6 +26,7 @@ class TestMP4 : public CppUnit::TestFixture
CPPUNIT_TEST(testCovrRead);
CPPUNIT_TEST(testCovrWrite);
CPPUNIT_TEST(testCovrRead2);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST_SUITE_END();
public:
@@ -224,6 +226,55 @@ public:
delete f;
}
void testProperties()
{
MP4::File f(TEST_FILE_PATH_C("has-tags.m4a"));
PropertyMap tags = f.properties();
CPPUNIT_ASSERT_EQUAL(StringList("Test Artist"), tags["ARTIST"]);
tags["TRACKNUMBER"] = StringList("2/4");
tags["DISCNUMBER"] = StringList("3/5");
tags["BPM"] = StringList("123");
tags["ARTIST"] = StringList("Foo Bar");
tags["COMPILATION"] = StringList("1");
f.setProperties(tags);
tags = f.properties();
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("trkn"));
CPPUNIT_ASSERT_EQUAL(2, f.tag()->itemListMap()["trkn"].toIntPair().first);
CPPUNIT_ASSERT_EQUAL(4, f.tag()->itemListMap()["trkn"].toIntPair().second);
CPPUNIT_ASSERT_EQUAL(StringList("2/4"), tags["TRACKNUMBER"]);
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("disk"));
CPPUNIT_ASSERT_EQUAL(3, f.tag()->itemListMap()["disk"].toIntPair().first);
CPPUNIT_ASSERT_EQUAL(5, f.tag()->itemListMap()["disk"].toIntPair().second);
CPPUNIT_ASSERT_EQUAL(StringList("3/5"), tags["DISCNUMBER"]);
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("tmpo"));
CPPUNIT_ASSERT_EQUAL(123, f.tag()->itemListMap()["tmpo"].toInt());
CPPUNIT_ASSERT_EQUAL(StringList("123"), tags["BPM"]);
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("\251ART"));
CPPUNIT_ASSERT_EQUAL(StringList("Foo Bar"), f.tag()->itemListMap()["\251ART"].toStringList());
CPPUNIT_ASSERT_EQUAL(StringList("Foo Bar"), tags["ARTIST"]);
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("cpil"));
CPPUNIT_ASSERT_EQUAL(true, f.tag()->itemListMap()["cpil"].toBool());
CPPUNIT_ASSERT_EQUAL(StringList("1"), tags["COMPILATION"]);
tags["COMPILATION"] = StringList("0");
f.setProperties(tags);
tags = f.properties();
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("cpil"));
CPPUNIT_ASSERT_EQUAL(false, f.tag()->itemListMap()["cpil"].toBool());
CPPUNIT_ASSERT_EQUAL(StringList("0"), tags["COMPILATION"]);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestMP4);

View File

@@ -1,8 +1,8 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <mp4coverart.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;

View File

@@ -1,9 +1,9 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <mp4coverart.h>
#include <mp4item.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;

View File

@@ -1,8 +1,9 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tstring.h>
#include <mpegfile.h>
#include <id3v2tag.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
@@ -32,9 +33,12 @@ public:
String xxx = ByteVector(254, 'X');
MPEG::File f(newname.c_str());
CPPUNIT_ASSERT_EQUAL(false, f.hasID3v2Tag());
f.tag()->setTitle(xxx);
f.tag()->setArtist("Artist A");
f.save(MPEG::File::AllTags, true, 4);
CPPUNIT_ASSERT_EQUAL(true, f.hasID3v2Tag());
MPEG::File f2(newname.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f2.ID3v2Tag()->header()->majorVersion());
@@ -66,9 +70,12 @@ public:
String xxx = ByteVector(254, 'X');
MPEG::File f(newname.c_str());
CPPUNIT_ASSERT_EQUAL(false, f.hasID3v2Tag());
f.tag()->setTitle(xxx);
f.tag()->setArtist("Artist A");
f.save(MPEG::File::AllTags, true, 3);
CPPUNIT_ASSERT_EQUAL(true, f.hasID3v2Tag());
MPEG::File f2(newname.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), f2.ID3v2Tag()->header()->majorVersion());

View File

@@ -1,4 +1,3 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
@@ -8,6 +7,7 @@
#include <oggfile.h>
#include <vorbisfile.h>
#include <oggpageheader.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
@@ -88,12 +88,12 @@ public:
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), tags["UNUSUALTAG"].size());
CPPUNIT_ASSERT_EQUAL(String("usual value"), tags["UNUSUALTAG"][0]);
CPPUNIT_ASSERT_EQUAL(String("another value"), tags["UNUSUALTAG"][1]);
CPPUNIT_ASSERT_EQUAL(String(L"öäüoΣø"), tags["UNICODETAG"][0]);
CPPUNIT_ASSERT_EQUAL(String("öäüoΣø", String::UTF8), tags["UNICODETAG"][0]);
tags["UNICODETAG"][0] = L"νεω ναλυε";
tags["UNICODETAG"][0] = String("νεω ναλυε", String::UTF8);
tags.erase("UNUSUALTAG");
f->tag()->setProperties(tags);
CPPUNIT_ASSERT_EQUAL(String(L"νεω ναλυε"), f->tag()->properties()["UNICODETAG"][0]);
CPPUNIT_ASSERT_EQUAL(String("νεω ναλυε", String::UTF8), f->tag()->properties()["UNICODETAG"][0]);
CPPUNIT_ASSERT_EQUAL(false, f->tag()->properties().contains("UNUSUALTAG"));
delete f;

View File

@@ -1,4 +1,3 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
@@ -6,6 +5,7 @@
#include <tbytevectorlist.h>
#include <oggfile.h>
#include <oggflacfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;

61
tests/test_opus.cpp Normal file
View File

@@ -0,0 +1,61 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tbytevectorlist.h>
#include <opusfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestOpus : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestOpus);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST(testReadComments);
CPPUNIT_TEST(testWriteComments);
CPPUNIT_TEST_SUITE_END();
public:
void testProperties()
{
Ogg::Opus::File f(TEST_FILE_PATH_C("correctness_gain_silent_output.opus"));
CPPUNIT_ASSERT_EQUAL(7, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(48000, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT_EQUAL(48000, ((Ogg::Opus::Properties *)f.audioProperties())->inputSampleRate());
}
void testReadComments()
{
Ogg::Opus::File f(TEST_FILE_PATH_C("correctness_gain_silent_output.opus"));
CPPUNIT_ASSERT_EQUAL(StringList("Xiph.Org Opus testvectormaker"), f.tag()->fieldListMap()["ENCODER"]);
CPPUNIT_ASSERT(f.tag()->fieldListMap().contains("TESTDESCRIPTION"));
CPPUNIT_ASSERT(!f.tag()->fieldListMap().contains("ARTIST"));
CPPUNIT_ASSERT_EQUAL(String("libopus 0.9.11-66-g64c2dd7"), f.tag()->vendorID());
}
void testWriteComments()
{
ScopedFileCopy copy("correctness_gain_silent_output", ".opus");
string filename = copy.fileName();
Ogg::Opus::File *f = new Ogg::Opus::File(filename.c_str());
f->tag()->setArtist("Your Tester");
f->save();
delete f;
f = new Ogg::Opus::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(StringList("Xiph.Org Opus testvectormaker"), f->tag()->fieldListMap()["ENCODER"]);
CPPUNIT_ASSERT(f->tag()->fieldListMap().contains("TESTDESCRIPTION"));
CPPUNIT_ASSERT_EQUAL(StringList("Your Tester"), f->tag()->fieldListMap()["ARTIST"]);
CPPUNIT_ASSERT_EQUAL(String("libopus 0.9.11-66-g64c2dd7"), f->tag()->vendorID());
delete f;
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestOpus);

View File

@@ -1,9 +1,9 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tbytevectorlist.h>
#include <rifffile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;

View File

@@ -19,8 +19,8 @@
* MA 02110-1301 USA *
***************************************************************************/
#include <cppunit/extensions/HelperMacros.h>
#include <s3mfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;

View File

@@ -22,9 +22,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <tstring.h>
#include <string.h>
#include <cppunit/extensions/HelperMacros.h>
using namespace std;
using namespace TagLib;
@@ -41,6 +41,7 @@ class TestString : public CppUnit::TestFixture
CPPUNIT_TEST(testAppendCharDetach);
CPPUNIT_TEST(testAppendStringDetach);
CPPUNIT_TEST(testToInt);
CPPUNIT_TEST(testSubstr);
CPPUNIT_TEST_SUITE_END();
public:
@@ -193,6 +194,13 @@ public:
CPPUNIT_ASSERT_EQUAL(String("-123aa").toInt(), -123);
}
void testSubstr()
{
CPPUNIT_ASSERT_EQUAL(String("01"), String("0123456").substr(0, 2));
CPPUNIT_ASSERT_EQUAL(String("12"), String("0123456").substr(1, 2));
CPPUNIT_ASSERT_EQUAL(String("123456"), String("0123456").substr(1, 200));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestString);

View File

@@ -22,8 +22,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <id3v2synchdata.h>
#include <cppunit/extensions/HelperMacros.h>
using namespace std;
using namespace TagLib;

View File

@@ -1,9 +1,9 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <xiphcomment.h>
#include <tpropertymap.h>
#include <tdebug.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;

View File

@@ -19,8 +19,8 @@
* MA 02110-1301 USA *
***************************************************************************/
#include <cppunit/extensions/HelperMacros.h>
#include <xmfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;

View File

@@ -7,6 +7,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#endif
#include <stdio.h>
#include <string.h>