Author: Amaury Forgeot d'Arc <[email protected]>
Branch:
Changeset: r54509:b58494d41466
Date: 2012-04-18 20:35 +0200
http://bitbucket.org/pypy/pypy/changeset/b58494d41466/
Log: (sbehnel) Improve tests for PyUnicode_Tailmatch
diff --git a/pypy/module/cpyext/test/test_unicodeobject.py
b/pypy/module/cpyext/test/test_unicodeobject.py
--- a/pypy/module/cpyext/test/test_unicodeobject.py
+++ b/pypy/module/cpyext/test/test_unicodeobject.py
@@ -453,10 +453,22 @@
def test_tailmatch(self, space, api):
w_str = space.wrap(u"abcdef")
- assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 2, 10, -1) ==
1
- assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 1, 5, 1) == 1
+ # prefix match
+ assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 2, 9, -1) == 1
+ assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 2, 4, -1) ==
0 # ends at 'd'
+ assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 1, 6, -1) ==
0 # starts at 'b'
+ assert api.PyUnicode_Tailmatch(w_str, space.wrap("cdf"), 2, 6, -1) == 0
+ # suffix match
+ assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 1, 5, 1) == 1
+ assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 3, 5, 1) ==
0 # starts at 'd'
+ assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 1, 6, 1) ==
0 # ends at 'f'
+ assert api.PyUnicode_Tailmatch(w_str, space.wrap("bde"), 1, 5, 1) == 0
+ # type checks
self.raises(space, api, TypeError,
api.PyUnicode_Tailmatch, w_str, space.wrap(3), 2, 10, 1)
+ self.raises(space, api, TypeError,
+ api.PyUnicode_Tailmatch, space.wrap(3), space.wrap("abc"),
+ 2, 10, 1)
def test_count(self, space, api):
w_str = space.wrap(u"abcabdab")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit