mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
21 lines
481 B
Python
21 lines
481 B
Python
|
from nose.tools import assert_equal
|
||
|
|
||
|
|
||
|
class TestFib(object):
|
||
|
|
||
|
def test_fib(self, func):
|
||
|
result = []
|
||
|
for i in xrange(num_items):
|
||
|
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()
|