mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-27 03:42:49 +00:00
Implement fast padding-less base64 encode/decode for python
This commit is contained in:
parent
a3c3e3ab6a
commit
b83e4d88f4
11 changed files with 197 additions and 44 deletions
|
|
@ -6,7 +6,7 @@ from base64 import standard_b64encode
|
|||
from binascii import hexlify
|
||||
from functools import partial
|
||||
|
||||
from kitty.fast_data_types import CURSOR_BLOCK, parse_bytes, parse_bytes_dump
|
||||
from kitty.fast_data_types import CURSOR_BLOCK, parse_bytes, parse_bytes_dump, base64_decode, base64_encode
|
||||
from kitty.notify import NotificationCommand, handle_notification_cmd, notification_activated, reset_registry
|
||||
|
||||
from . import BaseTest
|
||||
|
|
@ -41,6 +41,16 @@ class TestParser(BaseTest):
|
|||
q.append(('draw', current))
|
||||
self.ae(tuple(q), cmds)
|
||||
|
||||
def test_base64(self):
|
||||
for src, expected in {
|
||||
'bGlnaHQgdw==': 'light w',
|
||||
'bGlnaHQgd28=': 'light wo',
|
||||
'bGlnaHQgd29y': 'light wor',
|
||||
}.items():
|
||||
self.ae(base64_decode(src.encode()), expected.encode(), f'Decoding of {src} failed')
|
||||
self.ae(base64_decode(src.replace('=', '').encode()), expected.encode(), f'Decoding of {src} failed')
|
||||
self.ae(base64_encode(expected.encode()), src.replace('=', '').encode(), f'Encoding of {expected} failed')
|
||||
|
||||
def test_simple_parsing(self):
|
||||
s = self.create_screen()
|
||||
pb = partial(self.parse_bytes_dump, s)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue