##// END OF EJS Templates
hghave: fix dpkg --version check to work on recent dpkg versions...
hghave: fix dpkg --version check to work on recent dpkg versions Differential Revision: https://phab.mercurial-scm.org/D869

File last commit:

r33929:6c119dbf default
r34395:dbf83230 default
Show More
test-encoding-func.py
45 lines | 1.1 KiB | text/x-python | PythonLexer
/ tests / test-encoding-func.py
Yuya Nishihara
encoding: add function to test if a str consists of ASCII characters...
r33927 from __future__ import absolute_import
import unittest
from mercurial import (
encoding,
)
class IsasciistrTest(unittest.TestCase):
asciistrs = [
b'a',
b'ab',
b'abc',
b'abcd',
b'abcde',
b'abcdefghi',
b'abcd\0fghi',
]
def testascii(self):
for s in self.asciistrs:
self.assertTrue(encoding.isasciistr(s))
def testnonasciichar(self):
for s in self.asciistrs:
for i in range(len(s)):
t = bytearray(s)
t[i] |= 0x80
self.assertFalse(encoding.isasciistr(bytes(t)))
Yuya Nishihara
encoding: add fast path of from/tolocal() for ASCII strings...
r33928 class LocalEncodingTest(unittest.TestCase):
def testasciifastpath(self):
s = b'\0' * 100
self.assertTrue(s is encoding.tolocal(s))
self.assertTrue(s is encoding.fromlocal(s))
Yuya Nishihara
encoding: add fast path of from/toutf8b() for ASCII strings...
r33929 class Utf8bEncodingTest(unittest.TestCase):
def testasciifastpath(self):
s = b'\0' * 100
self.assertTrue(s is encoding.toutf8b(s))
self.assertTrue(s is encoding.fromutf8b(s))
Yuya Nishihara
encoding: add function to test if a str consists of ASCII characters...
r33927 if __name__ == '__main__':
import silenttestrunner
silenttestrunner.main(__name__)