From e6d141c8e711b7b60528fe0e8a1d0c379f94ad74 Mon Sep 17 00:00:00 2001 From: Simon Humpohl Date: Sat, 18 Apr 2020 13:05:42 +0200 Subject: [PATCH] Complete numeric test coverage --- tests/utils/numeric_tests.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/utils/numeric_tests.py b/tests/utils/numeric_tests.py index f020886da..dae89a0ca 100644 --- a/tests/utils/numeric_tests.py +++ b/tests/utils/numeric_tests.py @@ -82,6 +82,16 @@ def test_approximate_rational(self): result = approximate_rational(x + offset, abs_err, Fraction) self.assertEqual(expected, result) + with self.assertRaises(ValueError): + approximate_rational(Fraction(3, 1), Fraction(0, 100), Fraction) + + with self.assertRaises(ValueError): + approximate_rational(Fraction(3, 1), Fraction(-1, 100), Fraction) + + x = Fraction(3, 1) + abs_err = Fraction(1, 100) + self.assertIs(x, approximate_rational(x, abs_err, Fraction)) + def test_approximate_double(self): test_values = [ ((.1, .05), Fraction(1, 7)),