aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohannes Schickel2010-02-01 21:55:34 +0000
committerJohannes Schickel2010-02-01 21:55:34 +0000
commita7fb45927791e2d3d112f6fa020a0be9d0f82672 (patch)
tree61321ff488b78db3cb53721e2aa04640151fc463 /test
parent94e821f1eb8e0505a5f22423cd1e6d4b153fa182 (diff)
downloadscummvm-rg350-a7fb45927791e2d3d112f6fa020a0be9d0f82672.tar.gz
scummvm-rg350-a7fb45927791e2d3d112f6fa020a0be9d0f82672.tar.bz2
scummvm-rg350-a7fb45927791e2d3d112f6fa020a0be9d0f82672.zip
Add some basic tests for Audio::convertTimeToStreamPos.
svn-id: r47804
Diffstat (limited to 'test')
-rw-r--r--test/sound/audiostream.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/sound/audiostream.h b/test/sound/audiostream.h
new file mode 100644
index 0000000000..57ea27f62e
--- /dev/null
+++ b/test/sound/audiostream.h
@@ -0,0 +1,31 @@
+#include <cxxtest/TestSuite.h>
+
+#include "sound/audiostream.h"
+
+class AudioStreamTestSuite : public CxxTest::TestSuite
+{
+public:
+ void test_convertTimeToStreamPos() {
+ const Audio::Timestamp a = Audio::convertTimeToStreamPos(Audio::Timestamp(500, 1000), 11025, true);
+ // The last bit has to be 0 in any case for a stereo stream.
+ TS_ASSERT_EQUALS(a.totalNumberOfFrames() & 1, 0);
+
+ // TODO: This test is rather hacky... actually converTimeToStreamPos might also return 11026
+ // instead of 11024 and it would still be a valid sample position for ~500ms.
+ TS_ASSERT_EQUALS(a.totalNumberOfFrames(), 11024);
+
+ const Audio::Timestamp b = Audio::convertTimeToStreamPos(Audio::Timestamp(500, 1000), 11025, false);
+ TS_ASSERT_EQUALS(b.totalNumberOfFrames(), 500 * 11025 / 1000);
+
+ // Test Audio CD positioning
+
+ // for 44kHz and stereo
+ const Audio::Timestamp c = Audio::convertTimeToStreamPos(Audio::Timestamp(0, 50, 75), 44100, true);
+ TS_ASSERT_EQUALS(c.totalNumberOfFrames(), 50 * 44100 * 2 / 75);
+
+ // for 11kHz and mono
+ const Audio::Timestamp d = Audio::convertTimeToStreamPos(Audio::Timestamp(0, 50, 75), 11025, false);
+ TS_ASSERT_EQUALS(d.totalNumberOfFrames(), 50 * 11025 / 75);
+ }
+};
+