aboutsummaryrefslogtreecommitdiff
path: root/test/sound/timestamp.h
diff options
context:
space:
mode:
authorMax Horn2009-03-09 16:15:25 +0000
committerMax Horn2009-03-09 16:15:25 +0000
commit77b40251ca9f22b71680888ee6dd69e027f765ba (patch)
tree2b762887de27ccd4bea4119d273cb9beee015762 /test/sound/timestamp.h
parentb771aa5f0d51d9410c234f8a5c9e1915f7aa55d5 (diff)
downloadscummvm-rg350-77b40251ca9f22b71680888ee6dd69e027f765ba.tar.gz
scummvm-rg350-77b40251ca9f22b71680888ee6dd69e027f765ba.tar.bz2
scummvm-rg350-77b40251ca9f22b71680888ee6dd69e027f765ba.zip
Added some more Audio::Timestamp unit tests
svn-id: r39262
Diffstat (limited to 'test/sound/timestamp.h')
-rw-r--r--test/sound/timestamp.h35
1 files changed, 30 insertions, 5 deletions
diff --git a/test/sound/timestamp.h b/test/sound/timestamp.h
index d6477bc336..77ebdd909f 100644
--- a/test/sound/timestamp.h
+++ b/test/sound/timestamp.h
@@ -5,10 +5,10 @@
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);
+ void test_diff_add() {
+ const Audio::Timestamp a(10000, 1000);
+ const Audio::Timestamp b(10001, 1000);
+ const Audio::Timestamp c(10002, 1000);
TS_ASSERT_EQUALS(a.frameDiff(b), -1);
TS_ASSERT_EQUALS(b.frameDiff(a), 1);
@@ -23,7 +23,32 @@ class TimestampTestSuite : public CxxTest::TestSuite
TS_ASSERT_EQUALS(c.frameDiff(a), 2);
}
- void test_more_add_diff(void) {
+ void test_ticks() {
+ const Audio::Timestamp a(1234, 60);
+ const Audio::Timestamp b(5678, 60);
+
+ TS_ASSERT_EQUALS(a.msecs(), 1234);
+ TS_ASSERT_EQUALS(b.msecs(), 5678);
+
+ TS_ASSERT_EQUALS(a.msecsDiff(b), 1234 - 5678);
+ TS_ASSERT_EQUALS(b.msecsDiff(a), 5678 - 1234);
+
+ TS_ASSERT_EQUALS(a.frameDiff(b), (1234 - 5678) * 60 / 1000);
+ TS_ASSERT_EQUALS(b.frameDiff(a), (5678 - 1234) * 60 / 1000);
+
+ TS_ASSERT_EQUALS(a.addFrames(1).msecs(), 1234 + 1000 * 1/60);
+ TS_ASSERT_EQUALS(a.addFrames(59).msecs(), 1234 + 1000 * 59/60);
+ TS_ASSERT_EQUALS(a.addFrames(60).msecs(), 1234 + 1000 * 60/60);
+
+ // As soon as we go back even by only one frame, the msec value
+ // has to drop by at least one.
+ TS_ASSERT_EQUALS(a.addFrames(-1).msecs(), 1234 - 1000 * 1/60 - 1);
+ TS_ASSERT_EQUALS(a.addFrames(-59).msecs(), 1234 - 1000 * 59/60 - 1);
+ TS_ASSERT_EQUALS(a.addFrames(-60).msecs(), 1234 - 1000 * 60/60);
+ }
+
+
+ void test_more_add_diff() {
const Audio::Timestamp c(10002, 1000);
for (int i = -10000; i < 10000; i++) {