aboutsummaryrefslogtreecommitdiff
path: root/test/common
diff options
context:
space:
mode:
authorMax Horn2010-09-12 07:24:57 +0000
committerMax Horn2010-09-12 07:24:57 +0000
commit6bc9340df55d05ad7aa6b14348a567304ff41cc7 (patch)
tree438d7db5517e1130ab16275a36bcd7a3de33996d /test/common
parent8bc65ccdc7d5e7dc77600cdebc53b141473536dc (diff)
downloadscummvm-rg350-6bc9340df55d05ad7aa6b14348a567304ff41cc7.tar.gz
scummvm-rg350-6bc9340df55d05ad7aa6b14348a567304ff41cc7.tar.bz2
scummvm-rg350-6bc9340df55d05ad7aa6b14348a567304ff41cc7.zip
COMMON: Add unit tests for recently fixed Common::Rational bugs
Specifically, the bugs in operators - and / for mixed Rational/int args, fixed in rev #52675, are tested for. svn-id: r52680
Diffstat (limited to 'test/common')
-rw-r--r--test/common/rational.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/common/rational.h b/test/common/rational.h
index a55b0aed86..21b84a8a41 100644
--- a/test/common/rational.h
+++ b/test/common/rational.h
@@ -79,6 +79,11 @@ public:
TS_ASSERT_EQUALS(r1 + r0, Common::Rational(5, 2));
TS_ASSERT_EQUALS(r0 - r1, Common::Rational(3, 2));
TS_ASSERT_EQUALS(r1 - r0, Common::Rational(-3, 2));
+
+ TS_ASSERT_EQUALS(1 + r1, Common::Rational(3, 2));
+ TS_ASSERT_EQUALS(r1 + 1, Common::Rational(3, 2));
+ TS_ASSERT_EQUALS(1 - r1, Common::Rational(1, 2));
+ TS_ASSERT_EQUALS(r1 - 1, Common::Rational(-1, 2));
}
void test_mul() {
@@ -95,6 +100,9 @@ public:
TS_ASSERT_EQUALS((-r2) * r3, -r4);
TS_ASSERT_EQUALS(r2 * (-r3), -r4);
TS_ASSERT_EQUALS((-r2) * (-r3), r4);
+
+ TS_ASSERT_EQUALS(r1 * 2, 1);
+ TS_ASSERT_EQUALS(2 * r1, 1);
}
void test_div() {
@@ -102,5 +110,8 @@ public:
Common::Rational r1(1, 2);
TS_ASSERT_EQUALS(r0 / r1, 4);
+
+ TS_ASSERT_EQUALS(r1 / 2, Common::Rational(1, 4));
+ TS_ASSERT_EQUALS(2 / r1, Common::Rational(4, 1));
}
};