aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/dsd_stereo.wvbin0 -> 52595 bytes
-rw-r--r--tests/data/non_standard_rate.wvbin0 -> 132 bytes
-rw-r--r--tests/plainfile.h50
-rw-r--r--tests/test_file.cpp11
-rw-r--r--tests/test_id3v1.cpp13
-rw-r--r--tests/test_mp4.cpp59
-rw-r--r--tests/test_wavpack.cpp32
7 files changed, 155 insertions, 10 deletions
diff --git a/tests/data/dsd_stereo.wv b/tests/data/dsd_stereo.wv
new file mode 100644
index 00000000..80619270
--- /dev/null
+++ b/tests/data/dsd_stereo.wv
Binary files differ
diff --git a/tests/data/non_standard_rate.wv b/tests/data/non_standard_rate.wv
new file mode 100644
index 00000000..ccc90277
--- /dev/null
+++ b/tests/data/non_standard_rate.wv
Binary files differ
diff --git a/tests/plainfile.h b/tests/plainfile.h
new file mode 100644
index 00000000..6147b56b
--- /dev/null
+++ b/tests/plainfile.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ copyright : (C) 2015 by Tsuda Kageyu
+ email : tsuda.kageyu@gmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
+ * 02110-1301 USA *
+ * *
+ * Alternatively, this file is available under the Mozilla Public *
+ * License Version 1.1. You may obtain a copy of the License at *
+ * http://www.mozilla.org/MPL/ *
+ ***************************************************************************/
+
+#ifndef TAGLIB_PLAINFILE_H
+#define TAGLIB_PLAINFILE_H
+
+#include <tfile.h>
+
+using namespace TagLib;
+
+//! File subclass that gives tests access to filesystem operations
+class PlainFile : public File {
+public:
+ explicit PlainFile(FileName name) : File(name) { }
+ Tag *tag() const { return NULL; }
+ AudioProperties *audioProperties() const { return NULL; }
+ bool save() { return false; }
+ void truncate(long length) { File::truncate(length); }
+
+ ByteVector readAll() {
+ seek(0, End);
+ long end = tell();
+ seek(0);
+ return readBlock(end);
+ }
+};
+
+#endif
diff --git a/tests/test_file.cpp b/tests/test_file.cpp
index 9aae07fe..ef8c1b10 100644
--- a/tests/test_file.cpp
+++ b/tests/test_file.cpp
@@ -25,20 +25,11 @@
#include <tfile.h>
#include <cppunit/extensions/HelperMacros.h>
+#include "plainfile.h"
#include "utils.h"
using namespace TagLib;
-// File subclass that gives tests access to filesystem operations
-class PlainFile : public File {
-public:
- PlainFile(FileName name) : File(name) { }
- Tag *tag() const { return NULL; }
- AudioProperties *audioProperties() const { return NULL; }
- bool save(){ return false; }
- void truncate(long length) { File::truncate(length); }
-};
-
class TestFile : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestFile);
diff --git a/tests/test_id3v1.cpp b/tests/test_id3v1.cpp
index 3358aead..c50c3428 100644
--- a/tests/test_id3v1.cpp
+++ b/tests/test_id3v1.cpp
@@ -40,6 +40,7 @@ class TestID3v1 : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE(TestID3v1);
CPPUNIT_TEST(testStripWhiteSpace);
CPPUNIT_TEST(testGenres);
+ CPPUNIT_TEST(testRenamedGenres);
CPPUNIT_TEST_SUITE_END();
public:
@@ -68,6 +69,18 @@ public:
CPPUNIT_ASSERT_EQUAL(100, ID3v1::genreIndex("Humour"));
}
+ void testRenamedGenres()
+ {
+ CPPUNIT_ASSERT_EQUAL(String("Bebop"), ID3v1::genre(85));
+ CPPUNIT_ASSERT_EQUAL(85, ID3v1::genreIndex("Bebop"));
+ CPPUNIT_ASSERT_EQUAL(85, ID3v1::genreIndex("Bebob"));
+
+ ID3v1::Tag tag;
+ tag.setGenre("Hardcore");
+ CPPUNIT_ASSERT_EQUAL(String("Hardcore Techno"), tag.genre());
+ CPPUNIT_ASSERT_EQUAL(129U, tag.genreNumber());
+ }
+
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v1);
diff --git a/tests/test_mp4.cpp b/tests/test_mp4.cpp
index 05bf6bd3..9e52de2b 100644
--- a/tests/test_mp4.cpp
+++ b/tests/test_mp4.cpp
@@ -59,6 +59,7 @@ class TestMP4 : public CppUnit::TestFixture
CPPUNIT_TEST(testFuzzedFile);
CPPUNIT_TEST(testRepeatedSave);
CPPUNIT_TEST(testWithZeroLengthAtom);
+ CPPUNIT_TEST(testEmptyValuesRemoveItems);
CPPUNIT_TEST_SUITE_END();
public:
@@ -455,6 +456,64 @@ public:
CPPUNIT_ASSERT_EQUAL(22050, f.audioProperties()->sampleRate());
}
+ void testEmptyValuesRemoveItems()
+ {
+ const MP4::File f(TEST_FILE_PATH_C("has-tags.m4a"));
+ MP4::Tag *tag = f.tag();
+ const String testTitle("Title");
+ const String testArtist("Artist");
+ const String testAlbum("Album");
+ const String testComment("Comment");
+ const String testGenre("Genre");
+ const String nullString;
+ const unsigned int testYear = 2020;
+ const unsigned int testTrack = 1;
+ const unsigned int zeroUInt = 0;
+
+ tag->setTitle(testTitle);
+ CPPUNIT_ASSERT_EQUAL(testTitle, tag->title());
+ CPPUNIT_ASSERT(tag->contains("\251nam"));
+ tag->setArtist(testArtist);
+ CPPUNIT_ASSERT_EQUAL(testArtist, tag->artist());
+ CPPUNIT_ASSERT(tag->contains("\251ART"));
+ tag->setAlbum(testAlbum);
+ CPPUNIT_ASSERT_EQUAL(testAlbum, tag->album());
+ CPPUNIT_ASSERT(tag->contains("\251alb"));
+ tag->setComment(testComment);
+ CPPUNIT_ASSERT_EQUAL(testComment, tag->comment());
+ CPPUNIT_ASSERT(tag->contains("\251cmt"));
+ tag->setGenre(testGenre);
+ CPPUNIT_ASSERT_EQUAL(testGenre, tag->genre());
+ CPPUNIT_ASSERT(tag->contains("\251gen"));
+ tag->setYear(testYear);
+ CPPUNIT_ASSERT_EQUAL(testYear, tag->year());
+ CPPUNIT_ASSERT(tag->contains("\251day"));
+ tag->setTrack(testTrack);
+ CPPUNIT_ASSERT_EQUAL(testTrack, tag->track());
+ CPPUNIT_ASSERT(tag->contains("trkn"));
+
+ tag->setTitle(nullString);
+ CPPUNIT_ASSERT_EQUAL(nullString, tag->title());
+ CPPUNIT_ASSERT(!tag->contains("\251nam"));
+ tag->setArtist(nullString);
+ CPPUNIT_ASSERT_EQUAL(nullString, tag->artist());
+ CPPUNIT_ASSERT(!tag->contains("\251ART"));
+ tag->setAlbum(nullString);
+ CPPUNIT_ASSERT_EQUAL(nullString, tag->album());
+ CPPUNIT_ASSERT(!tag->contains("\251alb"));
+ tag->setComment(nullString);
+ CPPUNIT_ASSERT_EQUAL(nullString, tag->comment());
+ CPPUNIT_ASSERT(!tag->contains("\251cmt"));
+ tag->setGenre(nullString);
+ CPPUNIT_ASSERT_EQUAL(nullString, tag->genre());
+ CPPUNIT_ASSERT(!tag->contains("\251gen"));
+ tag->setYear(zeroUInt);
+ CPPUNIT_ASSERT_EQUAL(zeroUInt, tag->year());
+ CPPUNIT_ASSERT(!tag->contains("\251day"));
+ tag->setTrack(zeroUInt);
+ CPPUNIT_ASSERT_EQUAL(zeroUInt, tag->track());
+ CPPUNIT_ASSERT(!tag->contains("trkn"));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestMP4);
diff --git a/tests/test_wavpack.cpp b/tests/test_wavpack.cpp
index 6c64f08d..591529fb 100644
--- a/tests/test_wavpack.cpp
+++ b/tests/test_wavpack.cpp
@@ -41,6 +41,8 @@ class TestWavPack : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE(TestWavPack);
CPPUNIT_TEST(testNoLengthProperties);
CPPUNIT_TEST(testMultiChannelProperties);
+ CPPUNIT_TEST(testDsdStereoProperties);
+ CPPUNIT_TEST(testNonStandardRateProperties);
CPPUNIT_TEST(testTaggedProperties);
CPPUNIT_TEST(testFuzzedFile);
CPPUNIT_TEST(testStripAndProperties);
@@ -79,6 +81,36 @@ public:
CPPUNIT_ASSERT_EQUAL(1031, f.audioProperties()->version());
}
+ void testDsdStereoProperties()
+ {
+ WavPack::File f(TEST_FILE_PATH_C("dsd_stereo.wv"));
+ CPPUNIT_ASSERT(f.audioProperties());
+ CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->lengthInSeconds());
+ CPPUNIT_ASSERT_EQUAL(200, f.audioProperties()->lengthInMilliseconds());
+ CPPUNIT_ASSERT_EQUAL(2096, f.audioProperties()->bitrate());
+ CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
+ CPPUNIT_ASSERT_EQUAL(8, f.audioProperties()->bitsPerSample());
+ CPPUNIT_ASSERT_EQUAL(true, f.audioProperties()->isLossless());
+ CPPUNIT_ASSERT_EQUAL(352800, f.audioProperties()->sampleRate());
+ CPPUNIT_ASSERT_EQUAL(70560U, f.audioProperties()->sampleFrames());
+ CPPUNIT_ASSERT_EQUAL(1040, f.audioProperties()->version());
+ }
+
+ void testNonStandardRateProperties()
+ {
+ WavPack::File f(TEST_FILE_PATH_C("non_standard_rate.wv"));
+ CPPUNIT_ASSERT(f.audioProperties());
+ CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->lengthInSeconds());
+ CPPUNIT_ASSERT_EQUAL(3675, f.audioProperties()->lengthInMilliseconds());
+ CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
+ CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
+ CPPUNIT_ASSERT_EQUAL(16, f.audioProperties()->bitsPerSample());
+ CPPUNIT_ASSERT_EQUAL(true, f.audioProperties()->isLossless());
+ CPPUNIT_ASSERT_EQUAL(1000, f.audioProperties()->sampleRate());
+ CPPUNIT_ASSERT_EQUAL(3675U, f.audioProperties()->sampleFrames());
+ CPPUNIT_ASSERT_EQUAL(1040, f.audioProperties()->version());
+ }
+
void testTaggedProperties()
{
WavPack::File f(TEST_FILE_PATH_C("tagged.wv"));