diff options
author | Max Horn | 2010-01-06 12:09:14 +0000 |
---|---|---|
committer | Max Horn | 2010-01-06 12:09:14 +0000 |
commit | 5b635fd610a2d1f895adadbb43af3a76a36f1fd0 (patch) | |
tree | 8f0100d3eac84d0669bb37faf92b5c0955519507 /test | |
parent | 69566f6bf127af0ebdca73d2f33e30b6a0321094 (diff) | |
download | scummvm-rg350-5b635fd610a2d1f895adadbb43af3a76a36f1fd0.tar.gz scummvm-rg350-5b635fd610a2d1f895adadbb43af3a76a36f1fd0.tar.bz2 scummvm-rg350-5b635fd610a2d1f895adadbb43af3a76a36f1fd0.zip |
Change the way Timestamp stores its data.
Instead of storing milliseconds and frames (which causes rounding errors,
and causes ambiguity in how a given time is stored), we now do things
differently: We store a number of seconds, and frames. To make sure that
we can still handle milliseconds accurately, though, we change the
framerate to the least common multiple of the original framerate and
1000. So 60 becomes 6000, and 44100 becomes 441000. There are no visible
changes for client code, except for the increased accuracy.
svn-id: r47070
Diffstat (limited to 'test')
-rw-r--r-- | test/sound/timestamp.h | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/test/sound/timestamp.h b/test/sound/timestamp.h index 4945a18f88..d4cd0edc44 100644 --- a/test/sound/timestamp.h +++ b/test/sound/timestamp.h @@ -87,8 +87,32 @@ class TimestampTestSuite : public CxxTest::TestSuite void test_equals() { const Audio::Timestamp a = Audio::Timestamp(500, 1000); - const Audio::Timestamp b = Audio::Timestamp(0, 1000).addFrames(500); + Audio::Timestamp b = Audio::Timestamp(0, 1000); + Audio::Timestamp c = Audio::Timestamp(0, 100); + + TS_ASSERT(a != b); + TS_ASSERT(a != c); + TS_ASSERT(b == c); + + b = b.addFrames(500); + c = c.addFrames(50); TS_ASSERT(a == b); + TS_ASSERT(a == c); + TS_ASSERT(b == c); + } + + + void test_framerate() { + const Audio::Timestamp a = Audio::Timestamp(500, 1000); + const Audio::Timestamp b = Audio::Timestamp(500, 67); + const Audio::Timestamp c = Audio::Timestamp(500, 100); + const Audio::Timestamp d = Audio::Timestamp(500, 44100); + + + TS_ASSERT_EQUALS(a.getFramerate(), 1000); + TS_ASSERT_EQUALS(b.getFramerate(), 67); + TS_ASSERT_EQUALS(c.getFramerate(), 100); + TS_ASSERT_EQUALS(d.getFramerate(), 44100); } }; |