Skip to content

Commit

Permalink
100% coverage for the convert.py module
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-smallshire committed Feb 2, 2018
1 parent 61fef5f commit 87e46d5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from hypothesis import given, assume
from hypothesis.strategies import integers, floats
from math import factorial
from pytest import raises

from factoradic.convert import from_factoradic, to_factoradic
Expand Down Expand Up @@ -63,11 +64,26 @@ def test_non_integers_raise_value_error(n):
with raises(ValueError):
to_factoradic(n)


def test_nan_raises_value_error():
with raises(ValueError):
to_factoradic(float('nan'))


def test_infinity_raises_value_error():
with raises(ValueError):
to_factoradic(float('Inf'))


def test_empty_coefficients_raises_value_error():
with raises(ValueError):
from_factoradic([])


def test_out_of_range_coefficients_raise_value_error():
with raises(ValueError):
from_factoradic([1])

@given(m=integers(min_value=1, max_value=100))
def test_max_factoradic_is_one_less_than_factorial(m):
assert from_factoradic(range(m)) == factorial(m) - 1

0 comments on commit 87e46d5

Please sign in to comment.