diff options
author | Urs Fleisch <ufleisch@users.sourceforge.net> | 2020-12-28 09:16:44 +0100 |
---|---|---|
committer | Urs Fleisch <ufleisch@users.sourceforge.net> | 2020-12-28 09:16:44 +0100 |
commit | 5374cb1ac4e2bcdeedc88093c4afb263354694dd (patch) | |
tree | ccf27f26eda0c4781c7dec8f892c93a66ea39831 /tests | |
parent | 8a461ccedc86f5d10d4b2ff4115c1671489e0cac (diff) | |
parent | 741ed4e4bf2a3edabd00aa9ceb00d48047a0afcd (diff) |
Merge pull request #980 from ufleisch/ufleisch/wav-float-without-fact
Calculate bitrate for IEEE Float WAV files without fact chunk (#959)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_wav.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_wav.cpp b/tests/test_wav.cpp index c0717398..59484443 100644 --- a/tests/test_wav.cpp +++ b/tests/test_wav.cpp @@ -28,10 +28,12 @@ #include <id3v2tag.h> #include <infotag.h> #include <tbytevectorlist.h> +#include <tbytevectorstream.h> #include <tfilestream.h> #include <tpropertymap.h> #include <wavfile.h> #include <cppunit/extensions/HelperMacros.h> +#include "plainfile.h" #include "utils.h" using namespace std; @@ -43,6 +45,7 @@ class TestWAV : public CppUnit::TestFixture CPPUNIT_TEST(testPCMProperties); CPPUNIT_TEST(testALAWProperties); CPPUNIT_TEST(testFloatProperties); + CPPUNIT_TEST(testFloatWithoutFactChunkProperties); CPPUNIT_TEST(testZeroSizeDataChunk); CPPUNIT_TEST(testID3v2Tag); CPPUNIT_TEST(testSaveID3v23); @@ -100,6 +103,25 @@ public: CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->format()); } + void testFloatWithoutFactChunkProperties() + { + ByteVector wavData = PlainFile(TEST_FILE_PATH_C("float64.wav")).readAll(); + CPPUNIT_ASSERT_EQUAL(ByteVector("fact"), wavData.mid(36, 4)); + // Remove the fact chunk by renaming it to fakt + wavData[38] = 'k'; + ByteVectorStream wavStream(wavData); + RIFF::WAV::File f(&wavStream); + CPPUNIT_ASSERT(f.audioProperties()); + CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->lengthInSeconds()); + CPPUNIT_ASSERT_EQUAL(97, f.audioProperties()->lengthInMilliseconds()); + CPPUNIT_ASSERT_EQUAL(5645, f.audioProperties()->bitrate()); + CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels()); + CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate()); + CPPUNIT_ASSERT_EQUAL(64, f.audioProperties()->bitsPerSample()); + CPPUNIT_ASSERT_EQUAL(4281U, f.audioProperties()->sampleFrames()); + CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->format()); + } + void testZeroSizeDataChunk() { RIFF::WAV::File f(TEST_FILE_PATH_C("zero-size-chunk.wav")); |