More tests and micro-optimize switch to ASCII fast path

This commit is contained in:
Kovid Goyal
2024-01-11 12:13:59 +05:30
parent a63d62fb4e
commit b0dcdf74bd
2 changed files with 23 additions and 22 deletions

View File

@@ -181,19 +181,26 @@ class TestParser(BaseTest):
pb(b'"\xf0\x9f\x98"', '"\ufffd"')
def test_utf8_simd_decode(self):
def t(x, which=2, reset=True):
if reset:
test_utf8_decode_to_sentinel(b'', -1)
def reset_state():
test_utf8_decode_to_sentinel(b'', -1)
def t(x, which=2):
expected = test_utf8_decode_to_sentinel(x, 1)
actual = test_utf8_decode_to_sentinel(x, which)
self.ae(expected, actual, msg=f'Failed for {x!r} with {which=}\n{expected!r} !=\n{actual!r}')
for which in (2, 3):
x = partial(t, which=which)
x('2:α3')
x('2:α3:≤4:😸|')
x('abcd1234efgh5678')
x('abc\x1bd1234efgh5678')
x('abcd1234efgh5678ijklABCDmnopEFGH')
def double_test(x):
for which in (2, 3):
t(x)
t(x*2, which=3)
reset_state()
x = double_test
x('2:α3')
x('2:α3:≤4:😸|')
x('abcd1234efgh5678')
x('abc\x1bd1234efgh5678')
x('abcd1234efgh5678ijklABCDmnopEFGH')
def test_esc_codes(self):
s = self.create_screen()