Skip to content

Commit

Permalink
Complete numeric test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
terrorfisch committed Apr 18, 2020
1 parent d83612a commit e6d141c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/utils/numeric_tests.py
Expand Up @@ -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)),
Expand Down

0 comments on commit e6d141c

Please sign in to comment.