[Scummvm-cvs-logs] SF.net SVN: scummvm:[39262] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Mar 9 17:15:25 CET 2009


Revision: 39262
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39262&view=rev
Author:   fingolfin
Date:     2009-03-09 16:15:25 +0000 (Mon, 09 Mar 2009)

Log Message:
-----------
Added some more Audio::Timestamp unit tests

Modified Paths:
--------------
    scummvm/trunk/sound/timestamp.h
    scummvm/trunk/test/sound/timestamp.h

Modified: scummvm/trunk/sound/timestamp.h
===================================================================
--- scummvm/trunk/sound/timestamp.h	2009-03-09 08:38:02 UTC (rev 39261)
+++ scummvm/trunk/sound/timestamp.h	2009-03-09 16:15:25 UTC (rev 39262)
@@ -34,7 +34,7 @@
  * Timestamps allow measuring times with a sub-millisecond granularity,
  * and without rounding losses. This is achieved by measuring frames
  * instead of milliseconds: Specify an initial time in milliseconds
- * plus framerate (in Hertz, so frames per second).
+ * plus framerate (in frames per second).
  */
 class Timestamp {
 protected:

Modified: scummvm/trunk/test/sound/timestamp.h
===================================================================
--- scummvm/trunk/test/sound/timestamp.h	2009-03-09 08:38:02 UTC (rev 39261)
+++ scummvm/trunk/test/sound/timestamp.h	2009-03-09 16:15:25 UTC (rev 39262)
@@ -5,10 +5,10 @@
 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);
+	void test_diff_add() {
+		const Audio::Timestamp a(10000, 1000);
+		const Audio::Timestamp b(10001, 1000);
+		const Audio::Timestamp c(10002, 1000);
 	
 		TS_ASSERT_EQUALS(a.frameDiff(b), -1);
 		TS_ASSERT_EQUALS(b.frameDiff(a), 1);
@@ -23,7 +23,32 @@
 		TS_ASSERT_EQUALS(c.frameDiff(a), 2);
 	}
 
-	void test_more_add_diff(void) {
+	void test_ticks() {
+		const Audio::Timestamp a(1234, 60);
+		const Audio::Timestamp b(5678, 60);
+
+		TS_ASSERT_EQUALS(a.msecs(), 1234);
+		TS_ASSERT_EQUALS(b.msecs(), 5678);
+
+		TS_ASSERT_EQUALS(a.msecsDiff(b), 1234 - 5678);
+		TS_ASSERT_EQUALS(b.msecsDiff(a), 5678 - 1234);
+
+		TS_ASSERT_EQUALS(a.frameDiff(b), (1234 - 5678) * 60 / 1000);
+		TS_ASSERT_EQUALS(b.frameDiff(a), (5678 - 1234) * 60 / 1000);
+
+		TS_ASSERT_EQUALS(a.addFrames(1).msecs(), 1234 + 1000 * 1/60);
+		TS_ASSERT_EQUALS(a.addFrames(59).msecs(), 1234 + 1000 * 59/60);
+		TS_ASSERT_EQUALS(a.addFrames(60).msecs(), 1234 + 1000 * 60/60);
+
+		// As soon as we go back even by only one frame, the msec value
+		// has to drop by at least one.
+		TS_ASSERT_EQUALS(a.addFrames(-1).msecs(), 1234 - 1000 * 1/60 - 1);
+		TS_ASSERT_EQUALS(a.addFrames(-59).msecs(), 1234 - 1000 * 59/60 - 1);
+		TS_ASSERT_EQUALS(a.addFrames(-60).msecs(), 1234 - 1000 * 60/60);
+	}
+
+
+	void test_more_add_diff() {
 		const Audio::Timestamp c(10002, 1000);
 
 		for (int i = -10000; i < 10000; i++) {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list