Commit b02c0b09 authored by Robert Bradshaw's avatar Robert Bradshaw

More indexing tests

parent 43521474
...@@ -42,9 +42,9 @@ KeyError: 0 ...@@ -42,9 +42,9 @@ KeyError: 0
>>> test_del_int() >>> test_del_int()
Traceback (most recent call last): Traceback (most recent call last):
KeyError: 0 KeyError: 0
>>> test_del_uint() >>> test_del_uint() #doctest: +ELLIPSIS
Traceback (most recent call last): Traceback (most recent call last):
KeyError: 0 KeyError: 0...
>>> test_del_longlong() #doctest: +ELLIPSIS >>> test_del_longlong() #doctest: +ELLIPSIS
Traceback (most recent call last): Traceback (most recent call last):
KeyError: 0... KeyError: 0...
......
...@@ -42,6 +42,10 @@ IndexError: string index out of range ...@@ -42,6 +42,10 @@ IndexError: string index out of range
Traceback (most recent call last): Traceback (most recent call last):
... ...
TypeError: 'int' object is unsubscriptable TypeError: 'int' object is unsubscriptable
>>> test_unsigned_long()
>>> test_unsigned_short()
>>> test_long_long()
""" """
...@@ -53,3 +57,45 @@ def index_list(list L, int i): ...@@ -53,3 +57,45 @@ def index_list(list L, int i):
def index_object(object o, int i): def index_object(object o, int i):
return o[i] return o[i]
# These make sure that our fast indexing works with large and unsigned types.
def test_unsigned_long():
cdef int i
cdef unsigned long ix
cdef D = {}
for i from 0 <= i < sizeof(unsigned long) * 8:
ix = (<unsigned long>1) << i
D[ix] = True
for i from 0 <= i < sizeof(unsigned long) * 8:
ix = (<unsigned long>1) << i
assert D[ix] is True
del D[ix]
assert len(D) == 0
def test_unsigned_short():
cdef int i
cdef unsigned short ix
cdef D = {}
for i from 0 <= i < sizeof(unsigned short) * 8:
ix = (<unsigned short>1) << i
D[ix] = True
for i from 0 <= i < sizeof(unsigned short) * 8:
ix = (<unsigned short>1) << i
assert D[ix] is True
del D[ix]
assert len(D) == 0
def test_long_long():
cdef int i
cdef long long ix
cdef D = {}
for i from 0 <= i < sizeof(long long) * 8:
ix = (<long long>1) << i
D[ix] = True
for i from 0 <= i < sizeof(long long) * 8:
ix = (<long long>1) << i
assert D[ix] is True
del D[ix]
assert len(D) == 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment