aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2010-02-03 15:45:08 +0000
committerJohannes Schickel2010-02-03 15:45:08 +0000
commite9f831c1dabddb0ed700f0733313083dd8004564 (patch)
treead0fd3b94a0a7267dfe52fdece683491a1aacbaa
parent274f6e50337b3ec5d4e48eba9c3b03703491bc52 (diff)
downloadscummvm-rg350-e9f831c1dabddb0ed700f0733313083dd8004564.tar.gz
scummvm-rg350-e9f831c1dabddb0ed700f0733313083dd8004564.tar.bz2
scummvm-rg350-e9f831c1dabddb0ed700f0733313083dd8004564.zip
Some additional tests of RawStream::readBuffer.
svn-id: r47857
-rw-r--r--test/sound/raw.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/sound/raw.h b/test/sound/raw.h
index 6a6a23de3e..caeb79b7df 100644
--- a/test/sound/raw.h
+++ b/test/sound/raw.h
@@ -165,6 +165,47 @@ public:
delete s;
}
+ void test_partial_read() {
+ const int sampleRate = 11025;
+ const int time = 4;
+
+ int16 *sine;
+ Audio::SeekableAudioStream *s = createSineStream<int8>(sampleRate, time, &sine, false);
+ int16 *buffer = new int16[sampleRate * time];
+
+ TS_ASSERT_EQUALS(s->readBuffer(buffer, sampleRate), sampleRate);
+ TS_ASSERT_EQUALS(memcmp(sine, buffer, sampleRate), 0);
+ TS_ASSERT_EQUALS(s->endOfData(), false);
+
+ TS_ASSERT_EQUALS(s->readBuffer(buffer, sampleRate * 2), sampleRate * 2);
+ TS_ASSERT_EQUALS(memcmp(sine + sampleRate, buffer, sampleRate * 2), 0);
+ TS_ASSERT_EQUALS(s->endOfData(), false);
+
+ TS_ASSERT_EQUALS(s->readBuffer(buffer, sampleRate), sampleRate);
+ TS_ASSERT_EQUALS(memcmp(sine + sampleRate * 3, buffer, sampleRate), 0);
+ TS_ASSERT_EQUALS(s->endOfData(), true);
+
+ delete[] sine;
+ delete[] buffer;
+ delete s;
+ }
+
+ void test_read_after_end() {
+ const int sampleRate = 11025;
+ const int time = 1;
+ Audio::SeekableAudioStream *s = createSineStream<int8>(sampleRate, time, 0, false);
+ int16 *buffer = new int16[sampleRate * time];
+
+ TS_ASSERT_EQUALS(s->readBuffer(buffer, sampleRate * time), sampleRate * time);
+ TS_ASSERT_EQUALS(s->endOfData(), true);
+
+ TS_ASSERT_EQUALS(s->readBuffer(buffer, sampleRate * time), 0);
+ TS_ASSERT_EQUALS(s->endOfData(), true);
+
+ delete[] buffer;
+ delete s;
+ }
+
void test_rewind() {
const int sampleRate = 11025;
const int time = 2;