From 673a21b249d9a1753cb2622be1085636299e0990 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 4 Mar 2009 06:58:28 +0000 Subject: 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 --- test/module.mk | 4 ++-- test/sound/timestamp.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 test/sound/timestamp.h (limited to 'test') diff --git a/test/module.mk b/test/module.mk index 22c2dfa2c5..bf6a9efe8a 100644 --- a/test/module.mk +++ b/test/module.mk @@ -5,8 +5,8 @@ # ###################################################################### -TESTS := test/common/*.h -TEST_LIBS := common/libcommon.a +TESTS := test/common/*.h test/sound/*.h +TEST_LIBS := common/libcommon.a sound/libsound.a # TEST_FLAGS := --runner=StdioPrinter 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 + +#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); + } + } +}; -- cgit v1.2.3