-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_func.py
More file actions
56 lines (41 loc) · 1.6 KB
/
test_func.py
File metadata and controls
56 lines (41 loc) · 1.6 KB
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
"""
Unit tests for func.py
Converted from Idris2 func.idr
"""
import unittest
from func import api_function, _helper_function
class TestHelperFunction(unittest.TestCase):
"""Tests for the private helper function"""
def test_helper_function_positive(self):
"""Test helper function with positive number"""
self.assertEqual(_helper_function(5), 6)
def test_helper_function_zero(self):
"""Test helper function with zero"""
self.assertEqual(_helper_function(0), 1)
def test_helper_function_negative(self):
"""Test helper function with negative number"""
self.assertEqual(_helper_function(-3), -2)
class TestApiFunction(unittest.TestCase):
"""Tests for the public API function"""
def test_api_function_positive(self):
"""Test API function with positive number"""
# (5 + 1) * 2 = 12
self.assertEqual(api_function(5), 12)
def test_api_function_zero(self):
"""Test API function with zero"""
# (0 + 1) * 2 = 2
self.assertEqual(api_function(0), 2)
def test_api_function_negative(self):
"""Test API function with negative number"""
# (-3 + 1) * 2 = -4
self.assertEqual(api_function(-3), -4)
def test_api_function_large_number(self):
"""Test API function with large number"""
# (100 + 1) * 2 = 202
self.assertEqual(api_function(100), 202)
def test_api_function_type(self):
"""Test API function returns correct type"""
result = api_function(5)
self.assertIsInstance(result, int)
if __name__ == "__main__":
unittest.main()