From 5b635fd610a2d1f895adadbb43af3a76a36f1fd0 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 6 Jan 2010 12:09:14 +0000 Subject: 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 --- test/sound/timestamp.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'test/sound') 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); } }; -- cgit v1.2.3