@@ -21,13 +21,15 @@ def lower():
21
21
assert "DDd12Vv" .lower () == "ddd12vv"
22
22
assert "" .lower () == ""
23
23
24
+
24
25
def upper ():
25
26
s : str
26
27
s = "AaaaAABBbbbbBB!@12223BN"
27
28
assert s .upper () == "AAAAAABBBBBBBB!@12223BN"
28
29
assert "DDd12Vv" .upper () == "DDD12VV"
29
30
assert "" .upper () == ""
30
31
32
+
31
33
def strip ():
32
34
s : str
33
35
s = " AASAsaSas "
@@ -88,14 +90,15 @@ def startswith():
88
90
assert s .startswith ("sdd" ) == False
89
91
assert "" .startswith ("ok" ) == False
90
92
93
+
91
94
def endswith ():
92
95
93
96
# The following test suite fulfils the control flow graph coverage
94
97
# in terms of Statement Coverage and Branch Coverage associated with endwith() functionality.
95
98
96
- # Case 1: When string is constant and suffix is also constant
99
+ # Case 1: When string is constant and suffix is also constant
97
100
assert "" .endswith ("" ) == True
98
- assert "" .endswith (" " ) == False
101
+ assert "" .endswith (" " ) == False
99
102
assert "" .endswith ("%" ) == False
100
103
assert "" .endswith ("a1234PT#$" ) == False
101
104
assert "" .endswith ("blah blah" ) == False
@@ -105,13 +108,12 @@ def endswith():
105
108
assert " rendezvous 5:30 " .endswith ("apple" ) == False
106
109
assert "two plus" .endswith ("longer than string" ) == False
107
110
108
-
109
111
# Case 2: When string is constant and suffix is variable
110
112
suffix : str
111
113
suffix = ""
112
114
assert "" .endswith (suffix ) == True
113
115
suffix = " "
114
- assert "" .endswith (suffix ) == False
116
+ assert "" .endswith (suffix ) == False
115
117
suffix = "5:30 "
116
118
assert " rendezvous 5:30 " .endswith (suffix ) == True
117
119
suffix = ""
@@ -138,13 +140,14 @@ def endswith():
138
140
suffix = "apple"
139
141
assert s .endswith (suffix ) == False
140
142
143
+
141
144
def partition ():
142
-
143
- # Note: Both string or seperator cannot be empty
144
- # Case 1: When string is constant and seperator is also constant
145
- assert " " .partition (" " ) == ("" ," " ," " )
146
- assert "apple mango" .partition (" " ) == ("apple" ," " ,"mango" )
147
- assert "applemango" .partition ("afdnjkfsn" ) == ("applemango" ,"" ,"" )
145
+
146
+ # Note: Both string or seperator cannot be empty
147
+ # Case 1: When string is constant and seperator is also constant
148
+ assert " " .partition (" " ) == ("" , " " , " " )
149
+ assert "apple mango" .partition (" " ) == ("apple" , " " , "mango" )
150
+ assert "applemango" .partition ("afdnjkfsn" ) == ("applemango" , "" , "" )
148
151
assert "applemango" .partition ("an" ) == ("applem" , "an" , "go" )
149
152
assert "applemango" .partition ("mango" ) == ("apple" , "mango" , "" )
150
153
assert "applemango" .partition ("applemango" ) == ("" , "applemango" , "" )
@@ -154,15 +157,17 @@ def partition():
154
157
# Case 2: When string is constant and seperator is variable
155
158
seperator : str
156
159
seperator = " "
157
- assert " " .partition (seperator ) == ("" ," " ," " )
160
+ assert " " .partition (seperator ) == ("" , " " , " " )
158
161
seperator = " "
159
- assert "apple mango" .partition (seperator ) == ("apple" ," " ,"mango" )
162
+ assert "apple mango" .partition (seperator ) == ("apple" , " " , "mango" )
160
163
seperator = "5:30 "
161
- assert " rendezvous 5:30 " .partition (seperator ) == (" rendezvous " , "5:30 " , "" )
164
+ assert " rendezvous 5:30 " .partition (
165
+ seperator ) == (" rendezvous " , "5:30 " , "" )
162
166
seperator = "^&"
163
167
assert "@#$%^&*()#!" .partition (seperator ) == ("@#$%" , "^&" , "*()#!" )
164
168
seperator = "daddada "
165
- assert " rendezvous 5:30 " .partition (seperator ) == (" rendezvous 5:30 " , "" , "" )
169
+ assert " rendezvous 5:30 " .partition (
170
+ seperator ) == (" rendezvous 5:30 " , "" , "" )
166
171
seperator = "longer than string"
167
172
assert "two plus" .partition (seperator ) == ("two plus" , "" , "" )
168
173
@@ -182,6 +187,7 @@ def partition():
182
187
seperator = "apple"
183
188
assert s .partition (seperator ) == ("rendezvous 5" , "" , "" )
184
189
190
+
185
191
def is_lower ():
186
192
# Case 1: When constant string is present
187
193
assert "" .islower () == False
@@ -204,8 +210,9 @@ def is_lower():
204
210
s = "apple is a fruit"
205
211
assert s .islower () == True
206
212
213
+
207
214
def is_upper ():
208
- # Case 1: When constant string is present
215
+ # Case 1: When constant string is present
209
216
assert "" .isupper () == False
210
217
assert "apple" .isupper () == False
211
218
assert "4432632479" .isupper () == False
@@ -226,6 +233,7 @@ def is_upper():
226
233
s = "APPLE IS A FRUIT"
227
234
assert s .isupper () == True
228
235
236
+
229
237
def is_decimal ():
230
238
# Case 1: When constant string is present
231
239
assert "" .isdecimal () == False
@@ -251,6 +259,7 @@ def is_decimal():
251
259
s = "12 34"
252
260
assert s .isdecimal () == False
253
261
262
+
254
263
def is_ascii ():
255
264
# Case 1: When constant string is present
256
265
assert "" .isascii () == True
@@ -280,12 +289,16 @@ def is_ascii():
280
289
def is_space ():
281
290
assert "\n " .isspace () == True
282
291
assert " " .isspace () == True
283
- assert "\r " .isspace () == True
292
+ assert "\r " .isspace () == True
293
+ assert "" .isspace () == False
284
294
285
- s :str = " "
286
- assert s .isspace () == True
295
+ s : str = " "
296
+ assert s .isspace () == True
287
297
s = "a"
288
298
assert s .isspace () == False
299
+ s = ""
300
+ assert s .isspace () == False
301
+
289
302
290
303
def check ():
291
304
capitalize ()
@@ -303,4 +316,5 @@ def check():
303
316
is_ascii ()
304
317
is_space ()
305
318
319
+
306
320
check ()
0 commit comments