mirror of
https://github.com/taglib/taglib.git
synced 2025-07-22 15:04:24 -04:00
Merge branch 'master' into taglib2
This commit is contained in:
@ -27,6 +27,7 @@ INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/dsf
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ebml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ebml/matroska
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/dsdiff
|
||||
)
|
||||
|
||||
SET(test_runner_SRCS
|
||||
@ -72,6 +73,7 @@ SET(test_runner_SRCS
|
||||
test_speex.cpp
|
||||
test_dsf.cpp
|
||||
test_matroska.cpp
|
||||
test_dsdiff.cpp
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
|
||||
|
BIN
tests/data/empty10ms.dff
Normal file
BIN
tests/data/empty10ms.dff
Normal file
Binary file not shown.
BIN
tests/data/empty10ms.dsf
Normal file
BIN
tests/data/empty10ms.dsf
Normal file
Binary file not shown.
116
tests/test_dsdiff.cpp
Normal file
116
tests/test_dsdiff.cpp
Normal file
@ -0,0 +1,116 @@
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <dsdifffile.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace TagLib;
|
||||
|
||||
class TestDSDIFF : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestDSDIFF);
|
||||
CPPUNIT_TEST(testProperties);
|
||||
CPPUNIT_TEST(testTags);
|
||||
CPPUNIT_TEST(testSaveID3v2);
|
||||
CPPUNIT_TEST(testRepeatedSave);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
|
||||
void testProperties()
|
||||
{
|
||||
DSDIFF::File f(TEST_FILE_PATH_C("empty10ms.dff"));
|
||||
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(5644, f.audioProperties()->bitrate());
|
||||
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
|
||||
CPPUNIT_ASSERT_EQUAL(2822400, f.audioProperties()->sampleRate());
|
||||
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->bitsPerSample());
|
||||
CPPUNIT_ASSERT_EQUAL((long long)28224, f.audioProperties()->sampleCount());
|
||||
}
|
||||
|
||||
void testTags()
|
||||
{
|
||||
ScopedFileCopy copy("empty10ms", ".dff");
|
||||
string newname = copy.fileName();
|
||||
|
||||
DSDIFF::File *f = new DSDIFF::File(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), f->tag()->artist());
|
||||
f->tag()->setArtist("The Artist");
|
||||
f->save();
|
||||
delete f;
|
||||
|
||||
f = new DSDIFF::File(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String("The Artist"), f->tag()->artist());
|
||||
delete f;
|
||||
}
|
||||
|
||||
void testSaveID3v2()
|
||||
{
|
||||
ScopedFileCopy copy("empty10ms", ".dff");
|
||||
string newname = copy.fileName();
|
||||
|
||||
{
|
||||
DSDIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(!f.hasID3v2Tag());
|
||||
|
||||
f.tag()->setTitle(L"TitleXXX");
|
||||
f.save();
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
}
|
||||
{
|
||||
DSDIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L"TitleXXX"), f.tag()->title());
|
||||
|
||||
f.tag()->setTitle("");
|
||||
f.save();
|
||||
CPPUNIT_ASSERT(!f.hasID3v2Tag());
|
||||
}
|
||||
{
|
||||
DSDIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(!f.hasID3v2Tag());
|
||||
f.tag()->setTitle(L"TitleXXX");
|
||||
f.save();
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
}
|
||||
{
|
||||
DSDIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L"TitleXXX"), f.tag()->title());
|
||||
}
|
||||
}
|
||||
|
||||
void testRepeatedSave()
|
||||
{
|
||||
ScopedFileCopy copy("empty10ms", ".dff");
|
||||
string newname = copy.fileName();
|
||||
|
||||
{
|
||||
DSDIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), f.tag()->title());
|
||||
f.tag()->setTitle("NEW TITLE");
|
||||
f.save();
|
||||
CPPUNIT_ASSERT_EQUAL(String("NEW TITLE"), f.tag()->title());
|
||||
f.tag()->setTitle("NEW TITLE 2");
|
||||
f.save();
|
||||
CPPUNIT_ASSERT_EQUAL(String("NEW TITLE 2"), f.tag()->title());
|
||||
CPPUNIT_ASSERT_EQUAL(8252LL, f.length());
|
||||
f.save();
|
||||
CPPUNIT_ASSERT_EQUAL(8252LL, f.length());
|
||||
}
|
||||
{
|
||||
DSDIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String("NEW TITLE 2"), f.tag()->title());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestDSDIFF);
|
@ -12,13 +12,14 @@ using namespace TagLib;
|
||||
class TestDSF : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestDSF);
|
||||
CPPUNIT_TEST(testBasic);
|
||||
CPPUNIT_TEST(testBasic1);
|
||||
CPPUNIT_TEST(testBasic2);
|
||||
CPPUNIT_TEST(testTags);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
|
||||
void testBasic()
|
||||
void testBasic1()
|
||||
{
|
||||
DSF::File f(TEST_FILE_PATH_C("empty.dsf"));
|
||||
CPPUNIT_ASSERT(f.audioProperties());
|
||||
@ -33,12 +34,29 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->channelType());
|
||||
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->bitsPerSample());
|
||||
CPPUNIT_ASSERT_EQUAL((long long)0, f.audioProperties()->sampleCount());
|
||||
}
|
||||
|
||||
void testBasic2()
|
||||
{
|
||||
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());
|
||||
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
|
||||
CPPUNIT_ASSERT_EQUAL(2822400, f.audioProperties()->sampleRate());
|
||||
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->formatVersion());
|
||||
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->formatID());
|
||||
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channelType());
|
||||
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->bitsPerSample());
|
||||
CPPUNIT_ASSERT_EQUAL((long long)28224, f.audioProperties()->sampleCount());
|
||||
CPPUNIT_ASSERT_EQUAL(4096, f.audioProperties()->blockSizePerChannel());
|
||||
}
|
||||
|
||||
void testTags()
|
||||
{
|
||||
ScopedFileCopy copy("empty", ".dsf");
|
||||
ScopedFileCopy copy("empty10ms", ".dsf");
|
||||
string newname = copy.fileName();
|
||||
|
||||
DSF::File *f = new DSF::File(newname.c_str());
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include <wavfile.h>
|
||||
#include <apefile.h>
|
||||
#include <aifffile.h>
|
||||
#include <dsffile.h>
|
||||
#include <dsdifffile.h>
|
||||
#include <tfilestream.h>
|
||||
#include <tbytevectorstream.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
@ -79,6 +81,8 @@ class TestFileRef : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testWav);
|
||||
CPPUNIT_TEST(testAIFF_1);
|
||||
CPPUNIT_TEST(testAIFF_2);
|
||||
CPPUNIT_TEST(testDSF);
|
||||
CPPUNIT_TEST(testDSDIFF);
|
||||
CPPUNIT_TEST(testUnsupported);
|
||||
CPPUNIT_TEST(testFileResolver);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
@ -287,6 +291,16 @@ public:
|
||||
{
|
||||
fileRefSave<RIFF::AIFF::File>("alaw", ".aifc");
|
||||
}
|
||||
|
||||
void testDSF()
|
||||
{
|
||||
fileRefSave<DSF::File>("empty10ms",".dsf");
|
||||
}
|
||||
|
||||
void testDSDIFF()
|
||||
{
|
||||
fileRefSave<DSDIFF::File>("empty10ms",".dff");
|
||||
}
|
||||
|
||||
void testUnsupported()
|
||||
{
|
||||
|
@ -75,8 +75,8 @@ public:
|
||||
|
||||
void testToUIntBroken()
|
||||
{
|
||||
char data[] = { 0, 0, 0, -1 };
|
||||
char data2[] = { 0, 0, -1, -1 };
|
||||
char data[] = { 0, 0, 0, (char)-1 };
|
||||
char data2[] = { 0, 0, (char)-1, (char)-1 };
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)255, ID3v2::SynchData::toUInt(ByteVector(data, 4)));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)65535, ID3v2::SynchData::toUInt(ByteVector(data2, 4)));
|
||||
@ -84,7 +84,7 @@ public:
|
||||
|
||||
void testToUIntBrokenAndTooLarge()
|
||||
{
|
||||
char data[] = { 0, 0, 0, -1, 0 };
|
||||
char data[] = { 0, 0, 0, (char)-1, 0 };
|
||||
ByteVector v(data, 5);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)255, ID3v2::SynchData::toUInt(v));
|
||||
|
Reference in New Issue
Block a user