[PATCH 2 of 2] encoding: extend test cases for utf8b
Matt Mackall
mpm at selenic.com
Mon Nov 2 23:27:20 UTC 2015
# HG changeset patch
# User Matt Mackall <mpm at selenic.com>
# Date 1446506253 21600
# Mon Nov 02 17:17:33 2015 -0600
# Node ID a0664cf9d8d620ff82c5ec9954d7f58279c72dd8
# Parent 6bee6f327de32755da038193f453aa6bed6810c7
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.
diff -r 6bee6f327de3 -r a0664cf9d8d6 mercurial/encoding.py
--- a/mercurial/encoding.py Mon Nov 02 17:16:16 2015 -0600
+++ b/mercurial/encoding.py Mon Nov 02 17:17:33 2015 -0600
@@ -479,11 +479,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
'''
More information about the Mercurial-devel
mailing list