summaryrefslogtreecommitdiff
path: root/test/audiocachefiletest.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-01-28 11:41:18 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2016-01-28 11:41:18 +0100
commit3e829110a40f811a0216e3bc648bc7f2485f3b4d (patch)
tree807f931540ce39e8550d4c352e76e8b83c68caea /test/audiocachefiletest.cc
parent3cf2aec198526b2decd147a3d5a4c3e70a9708ef (diff)
Handle sndffile open failure.
Diffstat (limited to 'test/audiocachefiletest.cc')
-rw-r--r--test/audiocachefiletest.cc52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/audiocachefiletest.cc b/test/audiocachefiletest.cc
index fb454d2..7cb632b 100644
--- a/test/audiocachefiletest.cc
+++ b/test/audiocachefiletest.cc
@@ -52,6 +52,7 @@ class AudioCacheFileTest : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE(AudioCacheFileTest);
CPPUNIT_TEST(refTest);
CPPUNIT_TEST(readTest);
+ CPPUNIT_TEST(noFileTest);
CPPUNIT_TEST_SUITE_END();
public:
@@ -180,6 +181,57 @@ public:
}
}
+ void noFileTest()
+ {
+ size_t bufferSize = 64;
+ std::string filename = "kits/no-such-file.wav";
+
+ AudioCacheFile file(filename);
+ CPPUNIT_ASSERT_EQUAL(filename, file.getFilename());
+ CPPUNIT_ASSERT_EQUAL(0u, file.getSize());
+ CPPUNIT_ASSERT_EQUAL(0u, file.getChannelCount());
+
+ CacheChannels channels;
+
+ sample_t samples[13][bufferSize];
+ volatile bool ready[13];
+ for(size_t c = 0; c < 13; ++c)
+ {
+ for(size_t i = 0; i < bufferSize; ++i)
+ {
+ samples[c][i] = 42.0f;
+ }
+
+ channels.push_back(
+ {
+ c, // channel
+ samples[c], // samples
+ bufferSize, // max_num_samples
+ &ready[c] // ready
+ }
+ );
+ }
+
+ for(size_t c = 0; c < 13; ++c)
+ {
+ ready[c] = false;
+ }
+
+ file.readChunk(channels, 0, bufferSize);
+
+ for(size_t c = 0; c < 13; ++c)
+ {
+ CPPUNIT_ASSERT_EQUAL(false, ready[c]?true:false);
+ }
+
+ for(size_t c = 0; c < 13; ++c)
+ {
+ for(size_t i = 0; i < bufferSize; ++i)
+ {
+ CPPUNIT_ASSERT_EQUAL(42.0f, samples[c][i]);
+ }
+ }
+ }
};
// Registers the fixture into the 'registry'