From 4ae9412a3aea75990008c3a32080c54533fdb389 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 4 Jan 2010 22:48:28 +0000 Subject: Make some improvements for Audio::Timestamp. * Add convertToFramerate() method * Add framerate() method * Add operator == and != * Improve frameDiff() to work for two timestamps with distinct framerates * Improve Doxygen comments svn-id: r46994 --- test/sound/timestamp.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'test/sound/timestamp.h') diff --git a/test/sound/timestamp.h b/test/sound/timestamp.h index 89fc851a80..dccf67399c 100644 --- a/test/sound/timestamp.h +++ b/test/sound/timestamp.h @@ -47,7 +47,6 @@ class TimestampTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS(a.addFrames(-60).msecs(), (uint32)(1234 - 1000 * 60/60)); } - void test_more_add_diff() { const Audio::Timestamp c(10002, 1000); @@ -56,4 +55,33 @@ class TimestampTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS(v, i); } } + + + void test_diff_with_conversion() { + const Audio::Timestamp a = Audio::Timestamp(10, 1000).addFrames(20); + const Audio::Timestamp b = Audio::Timestamp(10, 1000/5).addFrames(20/5); + const Audio::Timestamp c = Audio::Timestamp(10, 1000*2).addFrames(20*2); + + TS_ASSERT_EQUALS(a.frameDiff(a), 0); + TS_ASSERT_EQUALS(a.frameDiff(b), 0); + TS_ASSERT_EQUALS(a.frameDiff(c), 0); + + TS_ASSERT_EQUALS(b.frameDiff(a), 0); + TS_ASSERT_EQUALS(b.frameDiff(b), 0); + TS_ASSERT_EQUALS(b.frameDiff(c), 0); + + TS_ASSERT_EQUALS(c.frameDiff(a), 0); + TS_ASSERT_EQUALS(c.frameDiff(b), 0); + TS_ASSERT_EQUALS(c.frameDiff(c), 0); + } + + + void test_convert() { + const Audio::Timestamp a = Audio::Timestamp(10, 1000).addFrames(20); + const Audio::Timestamp b = Audio::Timestamp(10, 1000/5).addFrames(20/5); + const Audio::Timestamp c = Audio::Timestamp(10, 1000*2).addFrames(20*2); + + TS_ASSERT_EQUALS(a.convertToFramerate(1000/5), b); + TS_ASSERT_EQUALS(a.convertToFramerate(1000*2), c); + } }; -- cgit v1.2.3