1
0
Fork 0
This commit is contained in:
s45158 2017-11-27 07:18:35 +01:00
parent 74b2516c90
commit 2e94abd6d3
1 changed files with 22 additions and 1 deletions

View File

@ -7,7 +7,28 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
""" """
def sum_from_one_to_n(n): def sum_from_one_to_n(n):
pass suma=0
if n > 0:
for i in range(1,n+1):
suma += i
return suma
def sum_from_one_to_n(n):
def test_special_cases(self):
"""Testy przypadków szczególnych."""
self.assertEqual(sum_from_one_to_n(-100), 0)
self.assertEqual(sum_from_one_to_n(-1), 0)
self.assertEqual(sum_from_one_to_n(0), 0)
self.assertEqual(sum_from_one_to_n(1), 1)
self.assertEqual(sum_from_one_to_n(2), 5)
def test_regular(self):
"""Testy dla kilku liczb"""
self.assertEqual(sum_from_one_to_n(3), 14)
self.assertEqual(sum_from_one_to_n(4), 385)
def tests(f): def tests(f):