forked from datosgobar/estandares
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_project_euler.py
56 lines (39 loc) · 1.34 KB
/
test_project_euler.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests methods to solve project euler problems."""
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import with_statement
import unittest
import nose
import project_euler as pe
class ProjectEulerTestCase(unittest.TestCase):
"""Tests for Project Euler methods."""
def test_calculate_multiples_sum(self):
"""Tests sum of multiples."""
multiples = [3]
limit = 3
res = pe.calculate_multiples_sum(multiples, limit)
exp = 3
self.assertEqual(res, exp)
def test_calculate_fibonacci_sum(self):
"""Tests sum of fibonacci numbers."""
res = pe.calculate_fibonacci_sum(1)
exp = 2
self.assertEqual(res, exp)
res = pe.calculate_fibonacci_sum(2)
exp = 4
self.assertEqual(res, exp)
res = pe.calculate_fibonacci_sum(4)
exp = 7
self.assertEqual(res, exp)
def test_calculate_largest_prime_factor(self):
"""Tests calculation of largest prime factor of a number."""
res = pe.calculate_largest_prime_factor(7)
exp = 7
self.assertEqual(res, exp)
res = pe.calculate_largest_prime_factor(13)
exp = 13
self.assertEqual(res, exp)
if __name__ == '__main__':
nose.run(defaultTest=__name__)