Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/encoding.py @ 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 | a24b98f4e03c |
children | b479fc425a81 |
comparison
equal
deleted
inserted
replaced
26962:fa2daf0e61ab | 26963:de5ae97ce9f4 |
---|---|
495 | 495 |
496 return the original binary string. This | 496 return the original binary string. This |
497 is a round-trip process for strings like filenames, but metadata | 497 is a round-trip process for strings like filenames, but metadata |
498 that's was passed through tolocal will remain in UTF-8. | 498 that's was passed through tolocal will remain in UTF-8. |
499 | 499 |
500 >>> roundtrip = lambda x: fromutf8b(toutf8b(x)) == x | |
500 >>> m = "\\xc3\\xa9\\x99abcd" | 501 >>> m = "\\xc3\\xa9\\x99abcd" |
501 >>> n = toutf8b(m) | 502 >>> toutf8b(m) |
502 >>> n | |
503 '\\xc3\\xa9\\xed\\xb2\\x99abcd' | 503 '\\xc3\\xa9\\xed\\xb2\\x99abcd' |
504 >>> fromutf8b(n) == m | 504 >>> roundtrip(m) |
505 True | |
506 >>> roundtrip("\\xc2\\xc2\\x80") | |
507 True | |
508 >>> roundtrip("\\xef\\xbf\\xbd") | |
509 True | |
510 >>> roundtrip("\\xef\\xef\\xbf\\xbd") | |
505 True | 511 True |
506 ''' | 512 ''' |
507 | 513 |
508 # fast path - look for uDxxx prefixes in s | 514 # fast path - look for uDxxx prefixes in s |
509 if "\xed" not in s: | 515 if "\xed" not in s: |