Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
065c06a6
Commit
065c06a6
authored
Dec 07, 2002
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add another test which exercises the whole suite with a
heapsort and verifies the result against list.sort().
parent
c2e095f6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
Lib/test/test_heapq.py
Lib/test/test_heapq.py
+14
-0
No files found.
Lib/test/test_heapq.py
View file @
065c06a6
...
...
@@ -70,6 +70,20 @@ def test_main():
if
item
>
heap
[
0
]:
# this gets rarer the longer we run
heapreplace
(
heap
,
item
)
vereq
(
list
(
heapiter
(
heap
)),
data_sorted
[
-
10
:])
# 6) Exercise everything with repeated heapsort checks
for
trial
in
xrange
(
100
):
size
=
random
.
randrange
(
50
)
data
=
[
random
.
randrange
(
25
)
for
i
in
range
(
size
)]
if
trial
&
1
:
# Half of the time, use heapify
heap
=
data
[:]
heapify
(
heap
)
else
:
# The rest of the time, use heappush
heap
=
[]
for
item
in
data
:
heappush
(
heap
,
item
)
data
.
sort
()
sorted
=
[
heappop
(
heap
)
for
i
in
range
(
size
)]
vereq
(
data
,
sorted
)
# Make user happy
if
verbose
:
print
"All OK"
...
...
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