Commit d0765682 authored by Stefan Behnel's avatar Stefan Behnel

rename auto encoding tests and add tests for c_string_type=unicode

--HG--
rename : tests/run/unicode_ascii_encoding.pyx => tests/run/str_ascii_auto_encoding.pyx
rename : tests/run/unicode_default_encoding.pyx => tests/run/str_default_auto_encoding.pyx
rename : tests/run/unicode_ascii_encoding.pyx => tests/run/unicode_ascii_auto_encoding.pyx
rename : tests/run/unicode_default_encoding.pyx => tests/run/unicode_default_auto_encoding.pyx
parent 5eaec9df
#cython: c_string_type = str
#cython: c_string_encoding = ascii
"End of first directives"
include "unicode_ascii_auto_encoding.pyx"
auto_string_type = str
def check_auto_string_type():
"""
>>> check_auto_string_type()
"""
assert auto_string_type is str
......@@ -10,4 +10,4 @@ if sys.version_info[0] >= 3:
True
"""
include "unicode_ascii_encoding.pyx"
include "str_ascii_auto_encoding.pyx"
#cython: c_string_type = str
#cython: c_string_type = unicode
#cython: c_string_encoding = ascii
auto_string_type = unicode
from libc.string cimport strcmp
def as_objects(char* ascii_data):
"""
>>> as_objects('abc')
'abc'
>>> print(as_objects('abc'))
abc
"""
assert isinstance(<object>ascii_data, str)
assert isinstance(<object>ascii_data, auto_string_type)
assert isinstance(<bytes>ascii_data, bytes)
assert isinstance(<str>ascii_data, str)
assert isinstance(<unicode>ascii_data, unicode)
......@@ -27,17 +30,17 @@ def from_object():
def slice_as_objects(char* ascii_data, int start, int end):
"""
>>> slice_as_objects('grok', 1, 3)
'ro'
>>> print(slice_as_objects('grok', 1, 3))
ro
"""
assert isinstance(<object>ascii_data[start:end], str)
assert isinstance(<object>ascii_data[start:end], auto_string_type)
assert isinstance(<bytes>ascii_data[start:end], bytes)
assert isinstance(<str>ascii_data[start:end], str)
assert isinstance(<unicode>ascii_data[start:end], unicode)
assert isinstance(<object>ascii_data[start:], str)
assert isinstance(<object>ascii_data[start:], auto_string_type)
assert isinstance(<bytes>ascii_data[start:], bytes)
assert isinstance(<str>ascii_data[start:], str)
assert isinstance(<unicode>ascii_data[start:], unicode)
return ascii_data[start:end]
# cython: c_string_type = unicode
# cython: c_string_encoding = default
import sys
if sys.version_info[0] >= 3:
__doc__ = r"""
>>> as_objects("ab\xff") == "ab\xff"
True
>>> slice_as_objects("ab\xffd", 1, 4) == "b\xff"
True
"""
include "unicode_ascii_auto_encoding.pyx"
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