mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
25 lines
513 B
Python
25 lines
513 B
Python
import unittest
|
|
|
|
|
|
class TestFib(unittest.TestCase):
|
|
|
|
def test_fib(self, func):
|
|
result = []
|
|
expected = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
|
|
for i in range(len(expected)):
|
|
result.append(func(i))
|
|
self.assertEqual(result, expected)
|
|
print('Success: test_fib')
|
|
|
|
|
|
def main():
|
|
test = TestFib()
|
|
math = Math()
|
|
test.test_fib(math.fib_recursive)
|
|
test.test_fib(math.fib_dynamic)
|
|
test.test_fib(math.fib_iterative)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|