mirror of
https://github.com/taglib/taglib.git
synced 2025-07-18 21:14:23 -04:00
DSF: Support frame factory, ID3v2.3, allow trailing garbage
Additionally test coverage and formatting are improved.
This commit is contained in:
@ -1,8 +1,11 @@
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <dsffile.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include "tbytevectorlist.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tag.h"
|
||||
#include "dsffile.h"
|
||||
#include "plainfile.h"
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
|
||||
@ -22,7 +25,6 @@ public:
|
||||
{
|
||||
DSF::File f(TEST_FILE_PATH_C("empty10ms.dsf"));
|
||||
CPPUNIT_ASSERT(f.audioProperties());
|
||||
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->length());
|
||||
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->lengthInSeconds());
|
||||
CPPUNIT_ASSERT_EQUAL(10, f.audioProperties()->lengthInMilliseconds());
|
||||
CPPUNIT_ASSERT_EQUAL(5645, f.audioProperties()->bitrate());
|
||||
@ -41,15 +43,30 @@ public:
|
||||
ScopedFileCopy copy("empty10ms", ".dsf");
|
||||
string newname = copy.fileName();
|
||||
|
||||
DSF::File *f = new DSF::File(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), f->tag()->artist());
|
||||
f->tag()->setArtist("The Artist");
|
||||
f->save();
|
||||
delete f;
|
||||
{
|
||||
DSF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(f.properties().isEmpty());
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), f.tag()->artist());
|
||||
f.tag()->setArtist("The Artist");
|
||||
PropertyMap properties = f.properties();
|
||||
properties["ALBUMARTIST"] = StringList("Album Artist");
|
||||
f.setProperties(properties);
|
||||
f.save();
|
||||
}
|
||||
|
||||
f = new DSF::File(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String("The Artist"), f->tag()->artist());
|
||||
delete f;
|
||||
{
|
||||
DSF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String("The Artist"), f.tag()->artist());
|
||||
CPPUNIT_ASSERT_EQUAL(String("The Artist"), f.properties()["ARTIST"].front());
|
||||
CPPUNIT_ASSERT_EQUAL(String("Album Artist"), f.properties()["ALBUMARTIST"].front());
|
||||
f.setProperties(PropertyMap());
|
||||
f.save();
|
||||
}
|
||||
|
||||
// Check if file without tags is same as original empty file
|
||||
const ByteVector dsfData = PlainFile(TEST_FILE_PATH_C("empty10ms.dsf")).readAll();
|
||||
const ByteVector fileData = PlainFile(newname.c_str()).readAll();
|
||||
CPPUNIT_ASSERT(dsfData == fileData);
|
||||
}
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user