Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
669fa188
Kaydet (Commit)
669fa188
authored
May 26, 2006
tarafından
Andrew Dalke
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added more rstrip tests, including for prealloc'ed arrays
üst
910a08f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
1 deletion
+54
-1
string_tests.py
Lib/test/string_tests.py
+54
-1
No files found.
Lib/test/string_tests.py
Dosyayı görüntüle @
669fa188
...
...
@@ -258,7 +258,7 @@ class CommonTest(unittest.TestCase):
aaa
=
' a '
*
20
self
.
checkequal
([
'a'
]
*
20
,
aaa
,
'split'
)
self
.
checkequal
([
'a'
]
+
[
aaa
[
4
:]],
aaa
,
'split'
,
None
,
1
)
self
.
checkequal
([
'a'
]
*
19
+
[
"a "
],
aaa
,
'split'
,
None
,
19
)
self
.
checkequal
([
'a'
]
*
19
+
[
'a '
],
aaa
,
'split'
,
None
,
19
)
# by a char
self
.
checkequal
([
'a'
,
'b'
,
'c'
,
'd'
],
'a|b|c|d'
,
'split'
,
'|'
)
...
...
@@ -291,6 +291,10 @@ class CommonTest(unittest.TestCase):
self
.
checkequal
([
'a//b//c//d'
],
'a//b//c//d'
,
'split'
,
'//'
,
0
)
self
.
checkequal
([
'a'
,
''
,
'b////c////d'
],
'a////b////c////d'
,
'split'
,
'//'
,
2
)
self
.
checkequal
([
'endcase '
,
''
],
'endcase test'
,
'split'
,
'test'
)
self
.
checkequal
([
''
,
' begincase'
],
'test begincase'
,
'split'
,
'test'
)
self
.
checkequal
([
''
,
' bothcase '
,
''
],
'test bothcase test'
,
'split'
,
'test'
)
self
.
checkequal
([
'a'
,
'bc'
],
'abbbc'
,
'split'
,
'bb'
)
self
.
checkequal
([
''
,
''
],
'aaa'
,
'split'
,
'aaa'
)
self
.
checkequal
([
'aaa'
],
'aaa'
,
'split'
,
'aaa'
,
0
)
self
.
checkequal
([
'ab'
,
'ab'
],
'abbaab'
,
'split'
,
'ba'
)
...
...
@@ -325,29 +329,74 @@ class CommonTest(unittest.TestCase):
self
.
checkequal
([
'a b'
,
'c'
,
'd'
],
'a b c d'
,
'rsplit'
,
None
,
2
)
self
.
checkequal
([
'a'
,
'b'
,
'c'
,
'd'
],
'a b c d'
,
'rsplit'
,
None
,
3
)
self
.
checkequal
([
'a'
,
'b'
,
'c'
,
'd'
],
'a b c d'
,
'rsplit'
,
None
,
4
)
self
.
checkequal
([
'a'
,
'b'
,
'c'
,
'd'
],
'a b c d'
,
'rsplit'
,
None
,
sys
.
maxint
-
20
)
self
.
checkequal
([
'a b c d'
],
'a b c d'
,
'rsplit'
,
None
,
0
)
self
.
checkequal
([
'a b'
,
'c'
,
'd'
],
'a b c d'
,
'rsplit'
,
None
,
2
)
self
.
checkequal
([],
' '
,
'rsplit'
)
self
.
checkequal
([
'a'
],
' a '
,
'rsplit'
)
self
.
checkequal
([
'a'
,
'b'
],
' a b '
,
'rsplit'
)
self
.
checkequal
([
' a'
,
'b'
],
' a b '
,
'rsplit'
,
None
,
1
)
self
.
checkequal
([
' a b'
,
'c'
],
' a b c '
,
'rsplit'
,
None
,
1
)
self
.
checkequal
([
' a'
,
'b'
,
'c'
],
' a b c '
,
'rsplit'
,
None
,
2
)
self
.
checkequal
([
'a'
,
'b'
],
'
\n\t
a
\t\r
b
\v
'
,
'rsplit'
,
None
,
88
)
aaa
=
' a '
*
20
self
.
checkequal
([
'a'
]
*
20
,
aaa
,
'rsplit'
)
self
.
checkequal
([
aaa
[:
-
4
]]
+
[
'a'
],
aaa
,
'rsplit'
,
None
,
1
)
self
.
checkequal
([
' a a'
]
+
[
'a'
]
*
18
,
aaa
,
'rsplit'
,
None
,
18
)
# by a char
self
.
checkequal
([
'a'
,
'b'
,
'c'
,
'd'
],
'a|b|c|d'
,
'rsplit'
,
'|'
)
self
.
checkequal
([
'a|b|c'
,
'd'
],
'a|b|c|d'
,
'rsplit'
,
'|'
,
1
)
self
.
checkequal
([
'a|b'
,
'c'
,
'd'
],
'a|b|c|d'
,
'rsplit'
,
'|'
,
2
)
self
.
checkequal
([
'a'
,
'b'
,
'c'
,
'd'
],
'a|b|c|d'
,
'rsplit'
,
'|'
,
3
)
self
.
checkequal
([
'a'
,
'b'
,
'c'
,
'd'
],
'a|b|c|d'
,
'rsplit'
,
'|'
,
4
)
self
.
checkequal
([
'a'
,
'b'
,
'c'
,
'd'
],
'a|b|c|d'
,
'rsplit'
,
'|'
,
sys
.
maxint
-
100
)
self
.
checkequal
([
'a|b|c|d'
],
'a|b|c|d'
,
'rsplit'
,
'|'
,
0
)
self
.
checkequal
([
'a||b||c'
,
''
,
'd'
],
'a||b||c||d'
,
'rsplit'
,
'|'
,
2
)
self
.
checkequal
([
''
,
' begincase'
],
'| begincase'
,
'rsplit'
,
'|'
)
self
.
checkequal
([
'endcase '
,
''
],
'endcase |'
,
'rsplit'
,
'|'
)
self
.
checkequal
([
''
,
'bothcase'
,
''
],
'|bothcase|'
,
'rsplit'
,
'|'
)
self
.
checkequal
([
'a
\x00\x00
b'
,
'c'
,
'd'
],
'a
\x00\x00
b
\x00
c
\x00
d'
,
'rsplit'
,
'
\x00
'
,
2
)
self
.
checkequal
([
'a'
]
*
20
,
(
'a|'
*
20
)[:
-
1
],
'rsplit'
,
'|'
)
self
.
checkequal
([
'a|a|a|a|a'
]
+
[
'a'
]
*
15
,
(
'a|'
*
20
)[:
-
1
],
'rsplit'
,
'|'
,
15
)
# by string
self
.
checkequal
([
'a'
,
'b'
,
'c'
,
'd'
],
'a//b//c//d'
,
'rsplit'
,
'//'
)
self
.
checkequal
([
'a//b//c'
,
'd'
],
'a//b//c//d'
,
'rsplit'
,
'//'
,
1
)
self
.
checkequal
([
'a//b'
,
'c'
,
'd'
],
'a//b//c//d'
,
'rsplit'
,
'//'
,
2
)
self
.
checkequal
([
'a'
,
'b'
,
'c'
,
'd'
],
'a//b//c//d'
,
'rsplit'
,
'//'
,
3
)
self
.
checkequal
([
'a'
,
'b'
,
'c'
,
'd'
],
'a//b//c//d'
,
'rsplit'
,
'//'
,
4
)
self
.
checkequal
([
'a'
,
'b'
,
'c'
,
'd'
],
'a//b//c//d'
,
'rsplit'
,
'//'
,
sys
.
maxint
-
5
)
self
.
checkequal
([
'a//b//c//d'
],
'a//b//c//d'
,
'rsplit'
,
'//'
,
0
)
self
.
checkequal
([
'a////b////c'
,
''
,
'd'
],
'a////b////c////d'
,
'rsplit'
,
'//'
,
2
)
self
.
checkequal
([
''
,
' begincase'
],
'test begincase'
,
'rsplit'
,
'test'
)
self
.
checkequal
([
'endcase '
,
''
],
'endcase test'
,
'rsplit'
,
'test'
)
self
.
checkequal
([
''
,
' bothcase '
,
''
],
'test bothcase test'
,
'rsplit'
,
'test'
)
self
.
checkequal
([
'ab'
,
'c'
],
'abbbc'
,
'rsplit'
,
'bb'
)
self
.
checkequal
([
''
,
''
],
'aaa'
,
'rsplit'
,
'aaa'
)
self
.
checkequal
([
'aaa'
],
'aaa'
,
'rsplit'
,
'aaa'
,
0
)
self
.
checkequal
([
'ab'
,
'ab'
],
'abbaab'
,
'rsplit'
,
'ba'
)
self
.
checkequal
([
'aaaa'
],
'aaaa'
,
'rsplit'
,
'aab'
)
self
.
checkequal
([
''
],
''
,
'rsplit'
,
'aaa'
)
self
.
checkequal
([
'aa'
],
'aa'
,
'rsplit'
,
'aaa'
)
self
.
checkequal
([
'bbob'
,
'A'
],
'bbobbbobbA'
,
'rsplit'
,
'bbobb'
)
self
.
checkequal
([
''
,
'B'
,
'A'
],
'bbobbBbbobbA'
,
'rsplit'
,
'bbobb'
)
self
.
checkequal
([
'a'
]
*
20
,
(
'aBLAH'
*
20
)[:
-
4
],
'rsplit'
,
'BLAH'
)
self
.
checkequal
([
'a'
]
*
20
,
(
'aBLAH'
*
20
)[:
-
4
],
'rsplit'
,
'BLAH'
,
19
)
self
.
checkequal
([
'aBLAHa'
]
+
[
'a'
]
*
18
,
(
'aBLAH'
*
20
)[:
-
4
],
'rsplit'
,
'BLAH'
,
18
)
# mixed use of str and unicode
self
.
checkequal
([
u'a b'
,
u'c'
,
u'd'
],
'a b c d'
,
'rsplit'
,
u' '
,
2
)
...
...
@@ -355,6 +404,10 @@ class CommonTest(unittest.TestCase):
# argument type
self
.
checkraises
(
TypeError
,
'hello'
,
'rsplit'
,
42
,
42
,
42
)
# null case
self
.
checkraises
(
ValueError
,
'hello'
,
'rsplit'
,
''
)
self
.
checkraises
(
ValueError
,
'hello'
,
'rsplit'
,
''
,
0
)
def
test_strip
(
self
):
self
.
checkequal
(
'hello'
,
' hello '
,
'strip'
)
self
.
checkequal
(
'hello '
,
' hello '
,
'lstrip'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment