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
d7be1186
Kaydet (Commit)
d7be1186
authored
Tem 08, 2004
tarafından
Neal Norwitz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Exercise some error conditions
üst
739a8f86
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
test_heapq.py
Lib/test/test_heapq.py
+10
-0
No files found.
Lib/test/test_heapq.py
Dosyayı görüntüle @
d7be1186
...
...
@@ -38,6 +38,10 @@ class TestHeap(unittest.TestCase):
# 2) Check that the invariant holds for a sorted array
self
.
check_invariant
(
results
)
self
.
assertRaises
(
TypeError
,
heappush
,
[])
self
.
assertRaises
(
TypeError
,
heappush
,
None
,
None
)
self
.
assertRaises
(
TypeError
,
heappop
,
None
)
def
check_invariant
(
self
,
heap
):
# Check the heap invariant.
for
pos
,
item
in
enumerate
(
heap
):
...
...
@@ -51,6 +55,8 @@ class TestHeap(unittest.TestCase):
heapify
(
heap
)
self
.
check_invariant
(
heap
)
self
.
assertRaises
(
TypeError
,
heapify
,
None
)
def
test_naive_nbest
(
self
):
data
=
[
random
.
randrange
(
2000
)
for
i
in
range
(
1000
)]
heap
=
[]
...
...
@@ -75,6 +81,10 @@ class TestHeap(unittest.TestCase):
heapreplace
(
heap
,
item
)
self
.
assertEqual
(
list
(
heapiter
(
heap
)),
sorted
(
data
)[
-
10
:])
self
.
assertRaises
(
TypeError
,
heapreplace
,
None
)
self
.
assertRaises
(
TypeError
,
heapreplace
,
None
,
None
)
self
.
assertRaises
(
IndexError
,
heapreplace
,
[],
None
)
def
test_heapsort
(
self
):
# Exercise everything with repeated heapsort checks
for
trial
in
xrange
(
100
):
...
...
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