Merge branch 'taglib2' of github.com:taglib/taglib into dsf

This commit is contained in:
Stephen F. Booth
2013-11-19 11:47:51 -05:00
36 changed files with 425 additions and 265 deletions

View File

@ -56,6 +56,7 @@ SET(test_runner_SRCS
test_ape.cpp
test_apetag.cpp
test_wav.cpp
test_info.cpp
test_wavpack.cpp
test_mp4.cpp
test_mp4item.cpp

View File

@ -232,6 +232,11 @@ public:
a.replace(ByteVector("ab"), ByteVector());
CPPUNIT_ASSERT_EQUAL(ByteVector("cdf"), a);
}
{
ByteVector a("abcdabf");
a.replace(ByteVector("bf"), ByteVector("x"));
CPPUNIT_ASSERT_EQUAL(ByteVector("abcdax"), a);
}
}
};

View File

@ -1,7 +1,10 @@
#include <string>
#include <stdio.h>
#include <tstring.h>
#include <mpegfile.h>
#include <id3v1tag.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
@ -16,8 +19,20 @@ public:
void testStripWhiteSpace()
{
ID3v1::StringHandler h;
CPPUNIT_ASSERT_EQUAL(String("Foo"), h.parse(ByteVector("Foo ")));
ScopedFileCopy copy("xing", ".mp3");
string newname = copy.fileName();
{
MPEG::File f(newname.c_str());
f.ID3v1Tag(true)->setArtist("Artist ");
f.save();
}
{
MPEG::File f(newname.c_str());
CPPUNIT_ASSERT(f.ID3v1Tag(false));
CPPUNIT_ASSERT_EQUAL(String("Artist"), f.ID3v1Tag(false)->artist());
}
}
};

View File

@ -1,9 +1,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <infotag.h>
#include <tpropertymap.h>
#include <tdebug.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
@ -23,7 +21,13 @@ public:
CPPUNIT_ASSERT_EQUAL(String(""), tag.title());
tag.setTitle("Test title 1");
tag.setFieldText("TEST", "Dummy Text");
CPPUNIT_ASSERT_EQUAL(String("Test title 1"), tag.title());
RIFF::Info::FieldListMap map = tag.fieldListMap();
CPPUNIT_ASSERT_EQUAL(String("Test title 1"), map["INAM"]);
CPPUNIT_ASSERT_EQUAL(String("Dummy Text"), map["TEST"]);
}
void testNumericFields()

View File

@ -39,6 +39,7 @@ public:
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT_EQUAL(16, ((MP4::AudioProperties *)f.audioProperties())->bitsPerSample());
CPPUNIT_ASSERT_EQUAL(MP4::AudioProperties::AAC, ((MP4::AudioProperties *)f.audioProperties())->codec());
}
void testPropertiesALAC()
@ -49,6 +50,7 @@ public:
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT_EQUAL(16, ((MP4::AudioProperties *)f.audioProperties())->bitsPerSample());
CPPUNIT_ASSERT_EQUAL(MP4::AudioProperties::ALAC, ((MP4::AudioProperties *)f.audioProperties())->codec());
}
void testCheckValid()

View File

@ -41,14 +41,28 @@ class TestString : public CppUnit::TestFixture
CPPUNIT_TEST(testAppendCharDetach);
CPPUNIT_TEST(testAppendStringDetach);
CPPUNIT_TEST(testToInt);
CPPUNIT_TEST(testFromInt);
CPPUNIT_TEST(testSubstr);
CPPUNIT_TEST(testNewline);
CPPUNIT_TEST(testUpper);
CPPUNIT_TEST_SUITE_END();
public:
void testString()
{
// Needs to know the system byte order for some Unicode tests.
bool littleEndian;
{
union {
int i;
char c;
} u;
u.i = 1;
littleEndian = (u.c == 1) ? true : false;
}
String s = "taglib string";
ByteVector v = "taglib string";
CPPUNIT_ASSERT(v == s.data(String::Latin1));
@ -72,8 +86,28 @@ public:
String unicode2(unicode.to8Bit(true), String::UTF8);
CPPUNIT_ASSERT(unicode == unicode2);
String unicode3(L"\u65E5\u672C\u8A9E");
CPPUNIT_ASSERT(*(unicode3.toCWString() + 1) == L'\u672C');
String unicode3(L"\u65E5\u672C\u8A9E");
CPPUNIT_ASSERT(*(unicode3.toCWString() + 1) == L'\u672C');
String unicode4(L"\u65e5\u672c\u8a9e");
CPPUNIT_ASSERT(unicode4[1] == L'\u672c');
String unicode5(L"\u65e5\u672c\u8a9e", String::UTF16BE);
CPPUNIT_ASSERT(unicode5[1] == (littleEndian ? L'\u2c67' : L'\u672c'));
String unicode6(L"\u65e5\u672c\u8a9e", String::UTF16LE);
CPPUNIT_ASSERT(unicode6[1] == (littleEndian ? L'\u672c' : L'\u2c67'));
wstring stduni = L"\u65e5\u672c\u8a9e";
String unicode7(stduni);
CPPUNIT_ASSERT(unicode7[1] == L'\u672c');
String unicode8(stduni, String::UTF16BE);
CPPUNIT_ASSERT(unicode8[1] == (littleEndian ? L'\u2c67' : L'\u672c'));
String unicode9(stduni, String::UTF16LE);
CPPUNIT_ASSERT(unicode9[1] == (littleEndian ? L'\u672c' : L'\u2c67'));
CPPUNIT_ASSERT(strcmp(String::number(0).toCString(), "0") == 0);
CPPUNIT_ASSERT(strcmp(String::number(12345678).toCString(), "12345678") == 0);
@ -215,6 +249,12 @@ public:
CPPUNIT_ASSERT_EQUAL(String("-123aa").toInt(), -123);
}
void testFromInt()
{
CPPUNIT_ASSERT_EQUAL(String("123"), String::number(123));
CPPUNIT_ASSERT_EQUAL(String("-123"), String::number(-123));
}
void testSubstr()
{
CPPUNIT_ASSERT_EQUAL(String("01"), String("0123456").substr(0, 2));
@ -237,6 +277,14 @@ public:
CPPUNIT_ASSERT_EQUAL(L'\x0d', String(crlf)[3]);
CPPUNIT_ASSERT_EQUAL(L'\x0a', String(crlf)[4]);
}
void testUpper()
{
String s1 = "tagLIB 012 strING";
String s2 = s1.upper();
CPPUNIT_ASSERT_EQUAL(String("tagLIB 012 strING"), s1);
CPPUNIT_ASSERT_EQUAL(String("TAGLIB 012 STRING"), s2);
}
};