-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_methods.py
More file actions
135 lines (82 loc) · 2.74 KB
/
Copy pathtest_methods.py
File metadata and controls
135 lines (82 loc) · 2.74 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import pytest
from cstring import cstring
def test_count():
target = cstring('hello, world')
assert target.count(cstring('l')) == 3
def test_count_start():
target = cstring('hello, world')
assert target.count(cstring('l'), 10) == 1
def test_count_end():
target = cstring('hello, world')
assert target.count(cstring('l'), 0, 4) == 2
def test_count_str_unicode():
target = cstring('🙂 🙃 🙂 🙂 🙃 🙂 🙂')
assert target.count('🙂') == 5
def test_find():
target = cstring('hello')
assert target.find('lo') == 3
def test_find_with_start():
target = cstring('hello')
assert target.find('lo', 3) == 3
def test_find_missing():
target = cstring('hello')
assert target.find('lo', 0, 4) == -1
def test_index():
target = cstring('hello')
assert target.index('lo') == 3
def test_index_with_start():
target = cstring('hello')
assert target.index('lo', 3) == 3
def test_index_missing():
target = cstring('hello')
with pytest.raises(ValueError):
return target.index('lo', 0, 4)
def test_rfind():
target = cstring('hello')
assert target.rfind('o') == 4
def test_rfind_empty():
target = cstring('hello')
assert target.rfind('') == 5
def test_rfind_with_start():
target = cstring('hello')
assert target.rfind('lo', 3) == 3
def test_rfind_missing():
target = cstring('hello')
assert target.rfind('lo', 0, 4) == -1
def test_rindex():
target = cstring('hello')
assert target.rindex('o') == 4
def test_rindex_empty():
target = cstring('hello')
assert target.rindex('') == 5
def test_rindex_with_start():
target = cstring('hello')
assert target.rindex('lo', 3) == 3
def test_rindex_missing():
target = cstring('hello')
with pytest.raises(ValueError):
return target.rindex('lo', 0, 4)
def test_startswith():
target = cstring('hello, world')
assert target.startswith('hello,') is True
def test_startswith_not():
target = cstring('hello, world')
assert target.startswith('world') is False
def test_startswith_with_start():
target = cstring('hello, world')
assert target.startswith('world', 7) is True
def test_startswith_with_start_and_end():
target = cstring('hello, world')
assert target.startswith('wo', 7, 8) is False
def test_endswith():
target = cstring('hello, world')
assert target.endswith('world') is True
def test_endswith_not():
target = cstring('hello, world')
assert target.endswith('hello') is False
def test_endswith_with_start():
target = cstring('hello, world')
assert target.endswith('world', 8) is False
def test_endswith_with_start_and_end():
target = cstring('hello, world')
assert target.endswith('wo', 7, 9) is True