aboutsummaryrefslogtreecommitdiffstats
path: root/unittest/rational.py
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-07-30 09:33:01 +0200
committerOlivier Tilloy <olivier@tilloy.net>2009-07-30 09:33:01 +0200
commit3a6ee939ff58bb7753afc111218c51daaf9ba532 (patch)
tree9118975620a5d23d23562734d4340ed32b3919e9 /unittest/rational.py
parentd0082eac5cfd6608994e0093def4054bc749e4b7 (diff)
downloadpyexiv2-3a6ee939ff58bb7753afc111218c51daaf9ba532.tar.gz
Rational.to_float().
Diffstat (limited to 'unittest/rational.py')
-rw-r--r--unittest/rational.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/unittest/rational.py b/unittest/rational.py
index 81edfb9..b10811d 100644
--- a/unittest/rational.py
+++ b/unittest/rational.py
@@ -48,6 +48,12 @@ class TestRational(unittest.TestCase):
self.assertEqual(str(Rational(3, 5)), '3/5')
self.assertEqual(str(Rational(-3, 5)), '-3/5')
+ def test_to_float(self):
+ self.assertEqual(Rational(3, 6).to_float(), 0.5)
+ self.assertEqual(Rational(11, 11).to_float(), 1.0)
+ self.assertEqual(Rational(-2, 8).to_float(), -0.25)
+ self.assertEqual(Rational(0, 3).to_float(), 0.0)
+
def test_equality(self):
r1 = Rational(2, 1)
r2 = Rational(2, 1)