forked from OmkarPathak/pygorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fibonacci.py
More file actions
32 lines (23 loc) · 941 Bytes
/
test_fibonacci.py
File metadata and controls
32 lines (23 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Test for Fibonacci implementations logic.
"""
import unittest
from pygorithm.fibonacci import generator, goldenratio, memoization, recursion
class TestFibonacciImplementations(unittest.TestCase):
"""
Tests for Fibonacci implementations.
"""
def test_implementations_same_result(self):
"""
Verify that all implementations have same result.
"""
fibonacci_implementations = [generator, goldenratio, memoization, recursion]
for implementation in fibonacci_implementations:
result = getattr(implementation, 'get_sequence')(0)
self.assertEqual([0], result)
result = getattr(implementation, 'get_sequence')(1)
self.assertEqual([0, 1], result)
result = getattr(implementation, 'get_sequence')(10)
self.assertEqual([0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55], result)
if __name__ == '__main__':
unittest.main()