changeset 26963:de5ae97ce9f4

encoding: extend test cases for utf8b This adds a round-trip helper and a few tests of streams that could cause synchronization problems in the encoder.
author Matt Mackall <mpm@selenic.com>
date Mon, 02 Nov 2015 17:17:33 -0600
parents fa2daf0e61ab
children 5abba2c92da3
files mercurial/encoding.py
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/encoding.py	Fri Nov 13 22:43:09 2015 -0800
+++ b/mercurial/encoding.py	Mon Nov 02 17:17:33 2015 -0600
@@ -497,11 +497,17 @@
     is a round-trip process for strings like filenames, but metadata
     that's was passed through tolocal will remain in UTF-8.
 
+    >>> roundtrip = lambda x: fromutf8b(toutf8b(x)) == x
     >>> m = "\\xc3\\xa9\\x99abcd"
-    >>> n = toutf8b(m)
-    >>> n
+    >>> toutf8b(m)
     '\\xc3\\xa9\\xed\\xb2\\x99abcd'
-    >>> fromutf8b(n) == m
+    >>> roundtrip(m)
+    True
+    >>> roundtrip("\\xc2\\xc2\\x80")
+    True
+    >>> roundtrip("\\xef\\xbf\\xbd")
+    True
+    >>> roundtrip("\\xef\\xef\\xbf\\xbd")
     True
     '''