diff options
author | Max Horn | 2009-03-04 06:58:28 +0000 |
---|---|---|
committer | Max Horn | 2009-03-04 06:58:28 +0000 |
commit | 673a21b249d9a1753cb2622be1085636299e0990 (patch) | |
tree | e3f44d6630c15f05e2effa42dfac5db5eb4cfb0f /test/sound | |
parent | 92eceb741ae713c5b2341543e249799e08c89b0d (diff) | |
download | scummvm-rg350-673a21b249d9a1753cb2622be1085636299e0990.tar.gz scummvm-rg350-673a21b249d9a1753cb2622be1085636299e0990.tar.bz2 scummvm-rg350-673a21b249d9a1753cb2622be1085636299e0990.zip |
Added Audio::Timestamp class, based on SCI's sfx_timestamp_t; also provide a unit test for it, based on the old (and very outdated) timetest.cpp. To be used by Audio::Mixer one day...
svn-id: r39112
Diffstat (limited to 'test/sound')
-rw-r--r-- | test/sound/timestamp.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/sound/timestamp.h b/test/sound/timestamp.h new file mode 100644 index 0000000000..d6477bc336 --- /dev/null +++ b/test/sound/timestamp.h @@ -0,0 +1,34 @@ +#include <cxxtest/TestSuite.h> + +#include "sound/timestamp.h" + +class TimestampTestSuite : public CxxTest::TestSuite +{ + public: + void test_diff_add(void) { + Audio::Timestamp a(10000, 1000); + Audio::Timestamp b(10001, 1000); + Audio::Timestamp c(10002, 1000); + + TS_ASSERT_EQUALS(a.frameDiff(b), -1); + TS_ASSERT_EQUALS(b.frameDiff(a), 1); + TS_ASSERT_EQUALS(c.frameDiff(a), 2); + TS_ASSERT_EQUALS(b.addFrames(2000).frameDiff(a), 2001); + TS_ASSERT_EQUALS(a.frameDiff(b), -1); + TS_ASSERT_EQUALS(b.frameDiff(a), 1); + TS_ASSERT_EQUALS(c.frameDiff(a), 2); + TS_ASSERT_EQUALS(b.addFrames(2000).frameDiff(a.addFrames(-1000)), 3001); + TS_ASSERT_EQUALS(a.frameDiff(b), -1); + TS_ASSERT_EQUALS(b.frameDiff(a), 1); + TS_ASSERT_EQUALS(c.frameDiff(a), 2); + } + + void test_more_add_diff(void) { + const Audio::Timestamp c(10002, 1000); + + for (int i = -10000; i < 10000; i++) { + int v = c.addFrames(i).frameDiff(c); + TS_ASSERT_EQUALS(v, i); + } + } +}; |