def test_read_name(self): """Test read_name.""" buf = bytearray(b'abc1\0hjk') cs = CodeStream(buf) assert cs.read_name() == b'ABC1' buf = bytearray(b' abc1$jhjk') cs = CodeStream(buf) assert cs.read_name() == b'ABC1$' buf = bytearray(b'1abc1$jhjk') cs = CodeStream(buf) assert cs.read_name() == b''
def test_read_number(self): """Test read_number.""" buf = bytearray(b'123ab') cs = CodeStream(buf) assert cs.read_number() == b'123' buf = bytearray(b'') cs = CodeStream(buf) assert cs.read_number() == b'' buf = bytearray(b'a') cs = CodeStream(buf) assert cs.read_number() == b'' buf = bytearray(b'&ha') cs = CodeStream(buf) assert cs.read_number() == b'&Ha' buf = bytearray(b'&7') cs = CodeStream(buf) assert cs.read_number() == b'&O7'
def test_backskip_blank(self): """Test backskip_blank.""" buf = bytearray(b'a \n\t b') cs = CodeStream(buf) cs.read(6) assert cs.backskip_blank() == b'a'
def test_read_to(self): """Test read_to.""" buf = bytearray(b'a \n\t b') cs = CodeStream(buf) assert cs.read_to(b' ') == b'a' assert cs.read_to(b'c') == b' \n\t b'
def test_read_string(self): """Test read_string.""" buf = bytearray(b'123ab') cs = CodeStream(buf) assert cs.read_string() == b'' buf = bytearray(b'"123ab"ghj') cs = CodeStream(buf) cs.end_line = (b'', b'\n') assert cs.read_string() == b'"123ab"' buf = bytearray(b'"123ab') cs = CodeStream(buf) cs.end_line = (b'', b'\n') assert cs.read_string() == b'"123ab'