mirror of
https://github.com/taglib/taglib.git
synced 2025-05-25 20:20:25 -04:00
Add unit tests
This commit is contained in:
parent
b53c08c067
commit
36d9c94f1f
@ -234,8 +234,9 @@ bool MPEG::File::save(int tags, bool stripOthers, int id3v2Version)
|
||||
// Dont save an APE-tag unless one has been created
|
||||
|
||||
if((APE & tags) && APETag()) {
|
||||
if(d->hasAPE)
|
||||
if(d->hasAPE) {
|
||||
insert(APETag()->render(), d->APELocation, d->APEOriginalSize);
|
||||
}
|
||||
else {
|
||||
if(d->hasID3v1) {
|
||||
insert(APETag()->render(), d->ID3v1Location, 0);
|
||||
@ -257,8 +258,9 @@ bool MPEG::File::save(int tags, bool stripOthers, int id3v2Version)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(d->hasAPE && stripOthers)
|
||||
else if(d->hasAPE && stripOthers) {
|
||||
success = strip(APE, false) && success;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
BIN
tests/data/apetag-replaygain-lyrics3v2.mp3
Normal file
BIN
tests/data/apetag-replaygain-lyrics3v2.mp3
Normal file
Binary file not shown.
BIN
tests/data/apetag-replaygain.mp3
Normal file
BIN
tests/data/apetag-replaygain.mp3
Normal file
Binary file not shown.
BIN
tests/data/lyrics3v2.mp3
Normal file
BIN
tests/data/lyrics3v2.mp3
Normal file
Binary file not shown.
@ -3,6 +3,7 @@
|
||||
#include <stdio.h>
|
||||
#include <mpegfile.h>
|
||||
#include <id3v2tag.h>
|
||||
#include <apetag.h>
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std;
|
||||
@ -15,6 +16,11 @@ class TestMPEG : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testSaveID3v24);
|
||||
CPPUNIT_TEST(testSaveID3v24WrongParam);
|
||||
CPPUNIT_TEST(testSaveID3v23);
|
||||
CPPUNIT_TEST(testReadAPEv2);
|
||||
CPPUNIT_TEST(testReadAPEv2WithLyrics3v2);
|
||||
CPPUNIT_TEST(testSaveAPEv2);
|
||||
CPPUNIT_TEST(testSaveAPEv2WithLyrics3v2);
|
||||
CPPUNIT_TEST(testSaveAPEv2EmptyWithLyrics3v2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -76,6 +82,75 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(xxx, f2.tag()->title());
|
||||
}
|
||||
|
||||
void testReadAPEv2()
|
||||
{
|
||||
ScopedFileCopy copy("apetag-replaygain", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
|
||||
MPEG::File f(newname.c_str());
|
||||
String s = f.APETag()->itemListMap()["MP3GAIN_ALBUM_MINMAX"].toString();
|
||||
CPPUNIT_ASSERT_EQUAL(String("129,170"), s);
|
||||
}
|
||||
|
||||
void testReadAPEv2WithLyrics3v2()
|
||||
{
|
||||
ScopedFileCopy copy("apetag-replaygain-lyrics3v2", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
|
||||
MPEG::File f(newname.c_str());
|
||||
String s = f.APETag()->itemListMap()["MP3GAIN_ALBUM_MINMAX"].toString();
|
||||
CPPUNIT_ASSERT_EQUAL(String("129,170"), s);
|
||||
}
|
||||
|
||||
void testSaveAPEv2()
|
||||
{
|
||||
ScopedFileCopy copy("apetag-replaygain", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
|
||||
MPEG::File f(newname.c_str());
|
||||
f.APETag()->addValue("MP3GAIN_ALBUM_MINMAX", String("xxx"));
|
||||
f.save();
|
||||
|
||||
MPEG::File f2(newname.c_str());
|
||||
String s = f2.APETag()->itemListMap()["MP3GAIN_ALBUM_MINMAX"].toString();
|
||||
CPPUNIT_ASSERT_EQUAL(String("xxx"), s);
|
||||
}
|
||||
|
||||
void testSaveAPEv2WithLyrics3v2()
|
||||
{
|
||||
ScopedFileCopy copy("apetag-replaygain-lyrics3v2", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
|
||||
MPEG::File f(newname.c_str());
|
||||
f.APETag()->addValue("MP3GAIN_ALBUM_MINMAX", String("xxx"));
|
||||
f.save();
|
||||
|
||||
MPEG::File f2(newname.c_str());
|
||||
String s = f2.APETag()->itemListMap()["MP3GAIN_ALBUM_MINMAX"].toString();
|
||||
CPPUNIT_ASSERT_EQUAL(String("xxx"), s);
|
||||
f2.seek(-9, File::End);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("LYRICS200"), f2.readBlock(9));
|
||||
}
|
||||
|
||||
void testSaveAPEv2EmptyWithLyrics3v2()
|
||||
{
|
||||
ScopedFileCopy copy("lyrics3v2", ".mp3", false);
|
||||
string newname = copy.fileName();
|
||||
|
||||
{
|
||||
MPEG::File f(newname.c_str());
|
||||
f.APETag(true)->addValue("MP3GAIN_ALBUM_MINMAX", String("xxx"));
|
||||
f.save();
|
||||
}
|
||||
|
||||
MPEG::File f2(newname.c_str());
|
||||
CPPUNIT_ASSERT(f2.APETag());
|
||||
String s = f2.APETag()->itemListMap()["MP3GAIN_ALBUM_MINMAX"].toString();
|
||||
CPPUNIT_ASSERT_EQUAL(String("xxx"), s);
|
||||
f2.seek(-9, File::End);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("LYRICS200"), f2.readBlock(9));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestMPEG);
|
||||
|
Loading…
Reference in New Issue
Block a user