Commit bdb3551b authored by Stefan Behnel's avatar Stefan Behnel

test fixes and extensions

parent 57773d75
cimport cython cimport cython
b_a = b'a'
b_b = b'b'
@cython.test_assert_path_exists( @cython.test_assert_path_exists(
"//PythonCapiCallNode") "//PythonCapiCallNode")
def bytes_startswith(bytes s, sub, start=None, stop=None): def bytes_startswith(bytes s, sub, start=None, stop=None):
""" """
>>> bytes_startswith(b'a', b'a') >>> bytes_startswith(b_a, b_a)
True
>>> bytes_startswith(b_a+b_b, b_a)
True True
>>> bytes_startswith(b'a', b'b') >>> bytes_startswith(b_a, b_b)
False
>>> bytes_startswith(b_a+b_b, b_b)
False False
>>> bytes_startswith(b'a', (b'a', b'b')) >>> bytes_startswith(b_a, (b_a, b_b))
True True
>>> bytes_startswith(b'a', b'a', 1) >>> bytes_startswith(b_a, b_a, 1)
False False
>>> bytes_startswith(b'a', b'a', 0, 0) >>> bytes_startswith(b_a, b_a, 0, 0)
False False
""" """
...@@ -27,15 +34,19 @@ def bytes_startswith(bytes s, sub, start=None, stop=None): ...@@ -27,15 +34,19 @@ def bytes_startswith(bytes s, sub, start=None, stop=None):
"//PythonCapiCallNode") "//PythonCapiCallNode")
def bytes_endswith(bytes s, sub, start=None, stop=None): def bytes_endswith(bytes s, sub, start=None, stop=None):
""" """
>>> bytes_endswith(b'a', b'a') >>> bytes_endswith(b_a, b_a)
True True
>>> bytes_endswith(b'a', b'b') >>> bytes_endswith(b_b+b_a, b_a)
True
>>> bytes_endswith(b_a, b_b)
False
>>> bytes_endswith(b_b+b_a, b_b)
False False
>>> bytes_endswith(b'a', (b'a', b'b')) >>> bytes_endswith(b_a, (b_a, b_b))
True True
>>> bytes_endswith(b'a', b'a', 1) >>> bytes_endswith(b_a, b_a, 1)
False False
>>> bytes_endswith(b'a', b'a', 0, 0) >>> bytes_endswith(b_a, b_a, 0, 0)
False False
""" """
......
...@@ -6,8 +6,12 @@ def str_startswith(str s, sub, start=None, stop=None): ...@@ -6,8 +6,12 @@ def str_startswith(str s, sub, start=None, stop=None):
""" """
>>> str_startswith('a', 'a') >>> str_startswith('a', 'a')
True True
>>> str_startswith('ab', 'a')
True
>>> str_startswith('a', 'b') >>> str_startswith('a', 'b')
False False
>>> str_startswith('ab', 'b')
False
>>> str_startswith('a', ('a', 'b')) >>> str_startswith('a', ('a', 'b'))
True True
>>> str_startswith('a', 'a', 1) >>> str_startswith('a', 'a', 1)
...@@ -29,8 +33,12 @@ def str_endswith(str s, sub, start=None, stop=None): ...@@ -29,8 +33,12 @@ def str_endswith(str s, sub, start=None, stop=None):
""" """
>>> str_endswith('a', 'a') >>> str_endswith('a', 'a')
True True
>>> str_endswith('ba', 'a')
True
>>> str_endswith('a', 'b') >>> str_endswith('a', 'b')
False False
>>> str_endswith('ba', 'b')
False
>>> str_endswith('a', ('a', 'b')) >>> str_endswith('a', ('a', 'b'))
True True
>>> str_endswith('a', 'a', 1) >>> str_endswith('a', 'a', 1)
......
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