def test_split_buffer_ecma_048_exclude_csi_sgr(): """Fail to split based on the ECMA-048 C1 CSI SGR. Added some intermediate characters to prevent matching other CSI codes; strictly checking empty SGR.""" data = 'Hello \x1b[!0World' expected = [['Hello \x1b[!0World', '']] assert repr(chromaterm.split_buffer(data)) == repr(expected)
def test_split_buffer_ecma_048_osc_title(): """Operating System Command (OSC) can supply arbitrary commands within the visible character set.""" for end in ['\x07', '\x1b\x5c']: osc = '\x1b]Ignored{}'.format(end) data = '{}Hello world'.format(osc) expected = [['', osc], ['Hello world', '']] assert repr(chromaterm.split_buffer(data)) == repr(expected)
def test_split_buffer_ecma_048_csi_no_parameter_no_intermediate(): """Split based on CSI with no parameter or intermediate bytes.""" csi_up_to_sgr = range(int('40', 16), int('6d', 16)) csi_above_sgr = range(int('6e', 16), int('7f', 16)) for char_id in itertools.chain(csi_up_to_sgr, csi_above_sgr): data = 'Hello \x1b[{} World'.format(chr(char_id)) expected = [['Hello ', '\x1b[' + chr(char_id)], [' World', '']] assert repr(chromaterm.split_buffer(data)) == repr(expected)
def test_split_buffer_ecma_048_c1_set(): """Split based on the ECMA-048 C1 set, excluding CSI.""" c1_set_up_to_csi = range(int('40', 16), int('5b', 16)) c1_set_above_csi = range(int('5c', 16), int('60', 16)) for char_id in itertools.chain(c1_set_up_to_csi, c1_set_above_csi): data = 'Hello \x1b{} World'.format(chr(char_id)) expected = [['Hello ', '\x1b' + chr(char_id)], [' World', '']] assert repr(chromaterm.split_buffer(data)) == repr(expected)
def test_split_buffer_ecma_048_csi_intermediate_no_parameter(): """Split based on CSI with intermediate bytes but no parameter bytes.""" csi_up_to_sgr = range(int('40', 16), int('6d', 16)) csi_above_sgr = range(int('6e', 16), int('7f', 16)) for char_id in itertools.chain(csi_up_to_sgr, csi_above_sgr): for intermediate in range(int('20', 16), int('30', 16)): for count in range(1, 4): code = chr(intermediate) * count + chr(char_id) data = 'Hello \x1b[{} World'.format(code) expected = [['Hello ', '\x1b[' + code], [' World', '']] assert repr(chromaterm.split_buffer(data)) == repr(expected)
def test_split_buffer_ecma_048_c1_set(): """Split based on the ECMA-048 C1 set, excluding CSI and OSC.""" c1_except_csi_and_osc = itertools.chain( range(int('40', 16), int('5b', 16)), [int('5c', 16), int('5e', 16), int('5f', 16)], ) for char_id in c1_except_csi_and_osc: data = 'Hello \x1b{} World'.format(chr(char_id)) expected = [['Hello ', '\x1b' + chr(char_id)], [' World', '']] assert repr(chromaterm.split_buffer(data)) == repr(expected)
def test_split_buffer_form_feed(): """Split based on \\f""" data = 'Hello \f World' expected = [['Hello ', '\f'], [' World', '']] assert repr(chromaterm.split_buffer(data)) == repr(expected)
def test_split_buffer_vertical_space(): """Split based on \\v""" data = 'Hello \v World' expected = [['Hello ', '\v'], [' World', '']] assert repr(chromaterm.split_buffer(data)) == repr(expected)
def test_split_buffer_new_line_n(): """Split based on \\n""" data = 'Hello \n World' expected = [['Hello ', '\n'], [' World', '']] assert repr(chromaterm.split_buffer(data)) == repr(expected)