def test_append_to_empty(): s = [] s[len(s):] = 'testing: \N{LONG LEFTWARDS ARROW}' s = ''.join(s) cs = codedstring() cs[len(s):] = 'testing: \N{LONG LEFTWARDS ARROW}' assert len(cs) == len(s) for idx in range(len(s)): assert s[idx] == cs[idx]
def test_default_buf(): cs = codedstring() assert cs.buffer is not None assert isinstance(cs.buffer, bytegapbuffer)
def test_initialisation(): s = 'abcd' b = s.encode('utf8') cs = codedstring(b)
def torture_string(): buf = TORTURE_BUF return ( codecs.decode(buf, 'utf-8', 'replace'), codedstring(bytegapbuffer(buf)) )
def demo_string(): buf = DEMO_BUF return codecs.decode(buf, 'utf-8'), codedstring(bytegapbuffer(buf))
def ascii_string(): s = 'hello, world' return s, codedstring(bytegapbuffer(s.encode('utf-8')))
def test_slice_empty(): cs = codedstring() assert cs[45:100] == ''
def empty_string(): s = '' return s, codedstring()