# HG changeset patch # User Matt Mackall # Date 1446506253 21600 # Node ID de5ae97ce9f424ac915d56fe6ed25932cf31ab6d # Parent fa2daf0e61abe57253325584976fbced0d7bcf6a 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 --git a/mercurial/encoding.py b/mercurial/encoding.py --- a/mercurial/encoding.py +++ b/mercurial/encoding.py @@ -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 '''