Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion exercises/rational-numbers/rational_numbers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from rational_numbers import Rational


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0

class RationalNumbersTest(unittest.TestCase):

Expand Down Expand Up @@ -71,9 +71,15 @@ def test_divide_by_one(self):
def test_absolute_value_of_positive(self):
self.assertEqual(abs(Rational(1, 2)), Rational(1, 2))

def test_absolute_value_of_positive_negative_numerator_denominator(self):
self.assertEqual(abs(Rational(-1, -2)), Rational(1, 2))

def test_absolute_value_of_negative(self):
self.assertEqual(abs(Rational(-1, 2)), Rational(1, 2))

def test_absolute_value_of_negative_with_negative_denominator(self):
self.assertEqual(abs(Rational(1, -2)), Rational(1, 2))

def test_absolute_value_of_zero(self):
self.assertEqual(abs(Rational(0, 1)), Rational(0, 1))

Expand Down