-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_main.py
More file actions
104 lines (72 loc) · 4.81 KB
/
test_main.py
File metadata and controls
104 lines (72 loc) · 4.81 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
"""
Zajęcia Python Luzino
Sławomir Jankowski
"""
import unittest
import string_processing
class TestGetResult(unittest.TestCase):
def test_get_current_processing_result(self):
string_to_test = string_processing.StringProcessing('To jest tekst testowy.')
expected_result = 'To jest tekst testowy.'
self.assertEqual(string_to_test.get_current_processing_result(), expected_result)
class TestTrimString(unittest.TestCase):
def test_trim_string_left(self):
string_to_test = string_processing.StringProcessing(' To jest tekst testowy.')
expected_result = 'To jest tekst testowy.'
string_to_test.trim_string()
self.assertEqual(string_to_test.get_current_processing_result(), expected_result)
def test_trim_string_right(self):
string_to_test = string_processing.StringProcessing('To jest tekst testowy. ')
expected_result = 'To jest tekst testowy.'
string_to_test.trim_string()
self.assertEqual(string_to_test.get_current_processing_result(), expected_result)
def test_trim_string_both(self):
string_to_test = string_processing.StringProcessing(' To jest tekst testowy. ')
expected_result = 'To jest tekst testowy.'
string_to_test.trim_string()
self.assertEqual(string_to_test.get_current_processing_result(), expected_result)
def test_trim_string_special_whitespaces(self):
string_to_test = string_processing.StringProcessing('\t \n \r \f To jest tekst testowy.\u2005 \u2007')
expected_result = 'To jest tekst testowy.'
string_to_test.trim_string()
self.assertEqual(string_to_test.get_current_processing_result(), expected_result)
class TestReplaceSubstring(unittest.TestCase):
def test_replace_substring_space_with_asterisk(self):
string_to_test = string_processing.StringProcessing('To jest tekst, w którym spacje zostaną zamienione na gwiazdki.')
expected_result = 'To*jest*tekst,*w*którym*spacje*zostaną*zamienione*na*gwiazdki.'
string_to_test.replace_substring(' ', '*')
self.assertEqual(string_to_test.get_current_processing_result(), expected_result)
def test_replace_substring_many_characters(self):
string_to_test = string_processing.StringProcessing('To jest ciąg znaków, w którym jedna sekwencja znaków zostanie zamieniona na inną sekwencję znaków.')
expected_result = 'To jest ciąg zębów, w którym jedna sekwencja zębów zostanie zamieniona na inną sekwencję zębów.'
string_to_test.replace_substring('znaków', 'zębów')
self.assertEqual(string_to_test.get_current_processing_result(), expected_result)
def test_replace_substring_with_empty_character(self):
string_to_test = string_processing.StringProcessing('To jest ciąg znaków, w którym pewna sekwencja znaków zostanie usunięta.')
expected_result = 'To jest ciąg zków, w którym pew sekwencja zków zostanie usunięta.'
string_to_test.replace_substring('na', '')
self.assertEqual(string_to_test.get_current_processing_result(), expected_result)
class TestAddPrefix(unittest.TestCase):
def test_add_prefix(self):
string_to_test = string_processing.StringProcessing('To jest tekst, do którego zostanie dodany ciąg znaków na początku.')
expected_result = '71830To jest tekst, do którego zostanie dodany ciąg znaków na początku.'
string_to_test.add_prefix('71830')
self.assertEqual(string_to_test.get_current_processing_result(), expected_result)
def test_add_prefix_existing(self):
string_to_test = string_processing.StringProcessing('71830To jest tekst, do którego nie zostanie dodany ciąg znaków na początku.')
expected_result = '71830To jest tekst, do którego nie zostanie dodany ciąg znaków na początku.'
string_to_test.add_prefix('71830')
self.assertEqual(string_to_test.get_current_processing_result(), expected_result)
class TestAddSuffix(unittest.TestCase):
def test_add_suffix(self):
string_to_test = string_processing.StringProcessing('To jest tekst, do którego zostanie dodany ciąg znaków na końcu.')
expected_result = 'To jest tekst, do którego zostanie dodany ciąg znaków na końcu.71830'
string_to_test.add_suffix('71830')
self.assertEqual(string_to_test.get_current_processing_result(), expected_result)
def test_add_suffix_existing(self):
string_to_test = string_processing.StringProcessing('To jest tekst, do którego nie zostanie dodany ciąg znaków na końcu.71830')
expected_result = 'To jest tekst, do którego nie zostanie dodany ciąg znaków na końcu.71830'
string_to_test.add_suffix('71830')
self.assertEqual(string_to_test.get_current_processing_result(), expected_result)
if __name__ == '__main__':
unittest.main()