diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/module.mk | 4 | ||||
-rw-r--r-- | test/sound/timestamp.h | 34 |
2 files changed, 36 insertions, 2 deletions
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 <cxxtest/TestSuite.h> + +#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); + } + } +}; |