-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_algorithm.py
55 lines (33 loc) · 921 Bytes
/
test_algorithm.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
import pytest
from algorithm import StringCalulator
# Global
sc_obj = StringCalulator()
def test_sum_empty():
assert 0 == sc_obj.sum()
def test_same_num():
num = "3"
assert 3 == sc_obj.sum(num)
def test_two_num():
num = "1,2"
assert 3 == sc_obj.sum(num)
def test_three_sum():
num = "1,2,3"
assert 6 == sc_obj.sum(num)
def test_new_line_sum():
num = "1\n,2,3"
assert 6 == sc_obj.sum(num)
def test_custom_delimiter_sum():
num = "//;\n1;2"
assert 3 == sc_obj.sum(num)
def test_single_negative_sum():
num = "-5"
assert "negatives not allowed: -5" == sc_obj.sum(num)
def test_multiple_negative_sum():
num = "4,-5,6,-7"
assert "negatives not allowed: -5 -7" == sc_obj.sum(num)
def test_single_thousands_sum():
num = "1001"
assert 0 == sc_obj.sum(num)
def test_multiple_thousands_sum():
num = "2,1001"
assert 2 == sc_obj.sum(num)