diff options
author | Max Horn | 2010-09-12 07:24:57 +0000 |
---|---|---|
committer | Max Horn | 2010-09-12 07:24:57 +0000 |
commit | 6bc9340df55d05ad7aa6b14348a567304ff41cc7 (patch) | |
tree | 438d7db5517e1130ab16275a36bcd7a3de33996d | |
parent | 8bc65ccdc7d5e7dc77600cdebc53b141473536dc (diff) | |
download | scummvm-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
-rw-r--r-- | test/common/rational.h | 11 |
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)); } }; |