zaut-2019/intro/Task104Test.py

38 lines
961 B
Python
Executable File

#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Zadanie 104
Napisz funkcję `sum_from_one_to_n` zwracającą sume kwadratów liczb od 1 do `n`.
Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
NAME: sum_from_one_to_n
PARAMS: int
RETURN: int
POINTS: 3
"""
import unittest
from Task104 import sum_from_one_to_n
class Task104Test(unittest.TestCase):
"""Testy do zadania 104"""
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), 30)
if __name__ == '__main__':
unittest.main()