aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2010-05-17 20:57:36 +0000
committerMatthew Hoops2010-05-17 20:57:36 +0000
commitea84abf5880f0af2642dd3de08a6d9c6f7f88426 (patch)
treef2350a83bbcd6af7010b29030366bade34392f9f
parent811fc0e7ec04950d0a4454d1780e49a4d87af9ae (diff)
downloadscummvm-rg350-ea84abf5880f0af2642dd3de08a6d9c6f7f88426.tar.gz
scummvm-rg350-ea84abf5880f0af2642dd3de08a6d9c6f7f88426.tar.bz2
scummvm-rg350-ea84abf5880f0af2642dd3de08a6d9c6f7f88426.zip
Add tests for Common::Rational from patch #2963496 (VideoDecoder Rewrite), also courtesy of DrMcCoy who wrote the main Common::Rational class too
svn-id: r49062
-rw-r--r--test/common/rational.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/common/rational.h b/test/common/rational.h
new file mode 100644
index 0000000000..f1a4ea6ab2
--- /dev/null
+++ b/test/common/rational.h
@@ -0,0 +1,38 @@
+#include <cxxtest/TestSuite.h>
+
+#include "common/rational.h"
+
+class RationalTestSuite : public CxxTest::TestSuite {
+public:
+ void test_operators() {
+ Common::Rational r0(6, 3);
+ Common::Rational r1(1, 2);
+
+ Common::Rational r2(62, 2);
+ Common::Rational r3(34, 4);
+
+ Common::Rational r4 = (r0 + r1) * 3;
+ Common::Rational r5 = (r2 - r3) / 3;
+
+ Common::Rational r6 = r5 - 1;
+
+ TS_ASSERT(r4 == r5);
+
+ TS_ASSERT(-r4 == -r5);
+
+ TS_ASSERT( r4 > r6);
+ TS_ASSERT( r4 >= r6);
+ TS_ASSERT(!(r4 < r6));
+ TS_ASSERT(!(r4 <= r6));
+
+ TS_ASSERT( r4 > 7);
+ TS_ASSERT( r4 >= 7);
+ TS_ASSERT(!(r4 < 7));
+ TS_ASSERT(!(r4 <= 7));
+
+ TS_ASSERT( 7 < r4);
+ TS_ASSERT( 7 <= r4);
+ TS_ASSERT(!(7 > r4));
+ TS_ASSERT(!(7 >= r4));
+ }
+};