From 4ba0ff8deb57aba3b034462c6c00ecf13ee281c9 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Thu, 11 Feb 2016 16:25:33 -0600 Subject: COMMON: Add convenience method to Common::Rational for 1:1 ratios For SCI engine games, ratios may not be normalised and so to avoid extra scaling, there needs to be a way to simply check whether a ratio is 1:1. --- test/common/rational.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/common') diff --git a/test/common/rational.h b/test/common/rational.h index 46dfc278c7..23d0c10acd 100644 --- a/test/common/rational.h +++ b/test/common/rational.h @@ -130,4 +130,15 @@ public: TS_ASSERT_EQUALS(r1 / 2, Common::Rational(1, 4)); TS_ASSERT_EQUALS(2 / r1, Common::Rational(4, 1)); } + + void test_isOne() { + Common::Rational r0(5, 5); + Common::Rational r1(1, 2); + Common::Rational r2(2, 1); + Common::Rational r3(1, 1); + TS_ASSERT(r0.isOne()); + TS_ASSERT(!r1.isOne()); + TS_ASSERT(!r2.isOne()); + TS_ASSERT(r3.isOne()); + } }; -- cgit v1.2.3