aboutsummaryrefslogtreecommitdiff
path: root/test/audio
diff options
context:
space:
mode:
authorBastien Bouclet2014-09-14 15:07:50 +0200
committerBastien Bouclet2014-12-20 19:38:18 +0100
commit200b05246c3e90e61fe6d2e21507b0b936d0ff2b (patch)
tree979a46fc580d65aa12d7e7c7cf27775aaacf3f03 /test/audio
parent0f590561bd0fe7238fcfd5fcee0d8a4dc11b9979 (diff)
downloadscummvm-rg350-200b05246c3e90e61fe6d2e21507b0b936d0ff2b.tar.gz
scummvm-rg350-200b05246c3e90e61fe6d2e21507b0b936d0ff2b.tar.bz2
scummvm-rg350-200b05246c3e90e61fe6d2e21507b0b936d0ff2b.zip
AUDIO: Wrap around in the Timestamp constructor
The "making of" video in the Xbox version of Myst III is unusually long. VideoDecoder::FixedRateVideoTrack::getFrameTime would trigger an overflow.
Diffstat (limited to 'test/audio')
-rw-r--r--test/audio/timestamp.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/audio/timestamp.h b/test/audio/timestamp.h
index ca56e34a4d..ec42a55ec4 100644
--- a/test/audio/timestamp.h
+++ b/test/audio/timestamp.h
@@ -2,6 +2,8 @@
#include "audio/timestamp.h"
+#include <limits.h>
+
class TimestampTestSuite : public CxxTest::TestSuite
{
public:
@@ -238,4 +240,15 @@ class TimestampTestSuite : public CxxTest::TestSuite
TS_ASSERT_EQUALS(c.numberOfFrames(), 11025);
TS_ASSERT_EQUALS(c.totalNumberOfFrames(), 33075);
}
+
+ void test_no_overflow() {
+ // The constructor should not overflow and give incoherent values
+ const Audio::Timestamp a = Audio::Timestamp(0, UINT_MAX, 1000);
+
+ int secs = UINT_MAX / 1000;
+ int frames = UINT_MAX % 1000;
+
+ TS_ASSERT_EQUALS(a.secs(), secs);
+ TS_ASSERT_EQUALS(a.numberOfFrames(), frames);
+ }
};