Author: fijal
Branch: unicode-utf8
Changeset: r93140:d24fe4f59c96
Date: 2017-11-23 15:57 +0100
http://bitbucket.org/pypy/pypy/changeset/d24fe4f59c96/
Log: provide explicit examples
diff --git a/rpython/rlib/test/test_rutf8.py b/rpython/rlib/test/test_rutf8.py
--- a/rpython/rlib/test/test_rutf8.py
+++ b/rpython/rlib/test/test_rutf8.py
@@ -30,6 +30,7 @@
@settings(max_examples=10000)
@given(strategies.binary(), strategies.booleans())
+@example('\xf1\x80\x80\x80', False)
def test_check_utf8(s, allow_surrogates):
_test_check_utf8(s, allow_surrogates)
@@ -134,19 +135,23 @@
assert repr(u) == repr_func(u.encode('utf8'))
@given(strategies.lists(strategies.characters()))
+@example([u'\ud800', u'\udc00'])
def test_surrogate_in_utf8(unichars):
uni = u''.join(unichars).encode('utf-8')
result = rutf8.surrogate_in_utf8(uni)
expected = any(uch for uch in unichars if u'\ud800' <= uch <= u'\udfff')
assert result == expected
-@given(strategies.text())
-def test_get_utf8_length_flag(u):
+@given(strategies.lists(strategies.characters()))
+def test_get_utf8_length_flag(unichars):
+ u = u''.join(unichars)
exp_lgt = len(u)
exp_flag = rutf8.FLAG_ASCII
for c in u:
if ord(c) > 0x7F:
exp_flag = rutf8.FLAG_REGULAR
+ if 0xD800 <= ord(c) <= 0xDFFF:
+ exp_flag = rutf8.FLAG_HAS_SURROGATES
lgt, flag = rutf8.get_utf8_length_flag(u.encode('utf8'))
assert lgt == exp_lgt
assert flag == exp_flag
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit