interactive-coding-challenges/recursion_dynamic/fibonacci/test_fibonacci.py

21 lines
476 B
Python
Raw Normal View History

2015-07-01 18:48:04 +08:00
from nose.tools import assert_equal
class TestFib(object):
2015-07-01 18:48:04 +08:00
def test_fib(self, func):
result = []
for i in range(num_items):
2015-07-01 18:48:04 +08:00
result.append(func(i))
fib_seq = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
assert_equal(result, fib_seq)
print('Success: test_fib')
def main():
test = TestFib()
test.test_fib(fib_recursive)
test.test_fib(fib_dynamic)
test.test_fib(fib_iterative)
if __name__ == '__main__':
main()