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
fb5b954e
Commit
fb5b954e
authored
May 16, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forward port additional tests from 2.7 (issue #14829).
parent
a103b96a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
3 deletions
+44
-3
Lib/test/test_bisect.py
Lib/test/test_bisect.py
+44
-3
No files found.
Lib/test/test_bisect.py
View file @
fb5b954e
...
...
@@ -23,6 +23,28 @@ del sys.modules['bisect']
import
bisect
as
c_bisect
class
Range
(
object
):
"""A trivial range()-like object without any integer width limitations."""
def
__init__
(
self
,
start
,
stop
):
self
.
start
=
start
self
.
stop
=
stop
self
.
last_insert
=
None
def
__len__
(
self
):
return
self
.
stop
-
self
.
start
def
__getitem__
(
self
,
idx
):
n
=
self
.
stop
-
self
.
start
if
idx
<
0
:
idx
+=
n
if
idx
>=
n
:
raise
IndexError
(
idx
)
return
self
.
start
+
idx
def
insert
(
self
,
idx
,
item
):
self
.
last_insert
=
idx
,
item
class
TestBisect
(
unittest
.
TestCase
):
module
=
None
...
...
@@ -125,9 +147,28 @@ class TestBisect(unittest.TestCase):
def
test_large_range
(
self
):
# Issue 13496
mod
=
self
.
module
data
=
range
(
sys
.
maxsize
-
1
)
self
.
assertEqual
(
mod
.
bisect_left
(
data
,
sys
.
maxsize
-
3
),
sys
.
maxsize
-
3
)
self
.
assertEqual
(
mod
.
bisect_right
(
data
,
sys
.
maxsize
-
3
),
sys
.
maxsize
-
2
)
n
=
sys
.
maxsize
data
=
range
(
n
-
1
)
self
.
assertEqual
(
mod
.
bisect_left
(
data
,
n
-
3
),
n
-
3
)
self
.
assertEqual
(
mod
.
bisect_right
(
data
,
n
-
3
),
n
-
2
)
self
.
assertEqual
(
mod
.
bisect_left
(
data
,
n
-
3
,
n
-
10
,
n
),
n
-
3
)
self
.
assertEqual
(
mod
.
bisect_right
(
data
,
n
-
3
,
n
-
10
,
n
),
n
-
2
)
def
test_large_pyrange
(
self
):
# Same as above, but without C-imposed limits on range() parameters
mod
=
self
.
module
n
=
sys
.
maxsize
data
=
Range
(
0
,
n
-
1
)
self
.
assertEqual
(
mod
.
bisect_left
(
data
,
n
-
3
),
n
-
3
)
self
.
assertEqual
(
mod
.
bisect_right
(
data
,
n
-
3
),
n
-
2
)
self
.
assertEqual
(
mod
.
bisect_left
(
data
,
n
-
3
,
n
-
10
,
n
),
n
-
3
)
self
.
assertEqual
(
mod
.
bisect_right
(
data
,
n
-
3
,
n
-
10
,
n
),
n
-
2
)
x
=
n
-
100
mod
.
insort_left
(
data
,
x
,
x
-
50
,
x
+
50
)
self
.
assertEqual
(
data
.
last_insert
,
(
x
,
x
))
x
=
n
-
200
mod
.
insort_right
(
data
,
x
,
x
-
50
,
x
+
50
)
self
.
assertEqual
(
data
.
last_insert
,
(
x
+
1
,
x
))
def
test_random
(
self
,
n
=
25
):
from
random
import
randrange
...
...
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