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
6aa1c3f4
Kaydet (Commit)
6aa1c3f4
authored
Ock 16, 2003
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Let test_random cover the endpoints.
Strengthen slicing tests. Improved variable names.
üst
a9f18dc0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
9 deletions
+20
-9
test_bisect.py
Lib/test/test_bisect.py
+20
-9
No files found.
Lib/test/test_bisect.py
Dosyayı görüntüle @
6aa1c3f4
...
...
@@ -87,15 +87,15 @@ class TestBisect(unittest.TestCase):
]
def
test_precomputed
(
self
):
for
func
,
list
,
elt
,
expected
in
self
.
precomputedCases
:
self
.
assertEqual
(
func
(
list
,
elt
),
expected
)
for
func
,
data
,
elem
,
expected
in
self
.
precomputedCases
:
self
.
assertEqual
(
func
(
data
,
elem
),
expected
)
def
test_random
(
self
,
n
=
2
0
):
def
test_random
(
self
,
n
=
2
5
):
from
random
import
randrange
for
i
in
xrange
(
n
):
data
=
[
randrange
(
0
,
n
,
2
)
for
j
in
xrange
(
i
)]
data
.
sort
()
elem
=
randrange
(
n
)
elem
=
randrange
(
-
1
,
n
+
1
)
ip
=
bisect_left
(
data
,
elem
)
if
ip
<
len
(
data
):
self
.
failUnless
(
elem
<=
data
[
ip
])
...
...
@@ -108,11 +108,22 @@ class TestBisect(unittest.TestCase):
self
.
failUnless
(
data
[
ip
-
1
]
<=
elem
)
def
test_optionalSlicing
(
self
):
for
func
,
list
,
elt
,
expected
in
self
.
precomputedCases
:
lo
=
min
(
len
(
list
),
1
)
self
.
failUnless
(
func
(
list
,
elt
,
lo
=
lo
)
>=
lo
)
hi
=
min
(
len
(
list
),
2
)
self
.
failUnless
(
func
(
list
,
elt
,
hi
=
hi
)
<=
hi
)
for
func
,
data
,
elem
,
expected
in
self
.
precomputedCases
:
for
lo
in
xrange
(
4
):
lo
=
min
(
len
(
data
),
lo
)
for
hi
in
xrange
(
3
,
8
):
hi
=
min
(
len
(
data
),
hi
)
ip
=
func
(
data
,
elem
,
lo
,
hi
)
self
.
failUnless
(
lo
<=
ip
<=
hi
)
if
func
is
bisect_left
and
ip
<
hi
:
self
.
failUnless
(
elem
<=
data
[
ip
])
if
func
is
bisect_left
and
ip
>
lo
:
self
.
failUnless
(
data
[
ip
-
1
]
<
elem
)
if
func
is
bisect_right
and
ip
<
hi
:
self
.
failUnless
(
elem
<
data
[
ip
])
if
func
is
bisect_right
and
ip
>
lo
:
self
.
failUnless
(
data
[
ip
-
1
]
<=
elem
)
self
.
assertEqual
(
ip
,
max
(
lo
,
min
(
hi
,
expected
)))
def
test_backcompatibility
(
self
):
self
.
assertEqual
(
bisect
,
bisect_right
)
...
...
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