Author: fijal
Branch: unicode-utf8
Changeset: r93143:e4a568e4514c
Date: 2017-11-23 16:32 +0100
http://bitbucket.org/pypy/pypy/changeset/e4a568e4514c/

Log:    more tests

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
@@ -154,8 +154,9 @@
         if 0xD800 <= ord(c) <= 0xDFFF:
             exp_flag = rutf8.FLAG_HAS_SURROGATES
             break
-    lgt, flag = rutf8.get_utf8_length_flag(u.encode('utf8'))
-    assert lgt == exp_lgt
+    lgt, flag = rutf8.get_utf8_length_flag(''.join([c.encode('utf8') for c in 
u]))
+    if exp_flag != rutf8.FLAG_HAS_SURROGATES:
+        assert lgt == exp_lgt
     assert flag == exp_flag
 
 def test_utf8_string_builder():
@@ -182,3 +183,11 @@
     s.append_code(0xD800)
     assert s.get_flag() == rutf8.FLAG_HAS_SURROGATES
     assert s.get_length() == 2
+
+@given(strategies.text())
+def test_utf8_iterator(arg):
+    u = rutf8.Utf8StringIterator(arg.encode('utf8'))
+    l = []
+    while not u.done():
+        l.append(unichr(u.next()))
+    assert list(arg) == l
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to