예제 #1
0
 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''
예제 #2
0
 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'
예제 #3
0
 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'
예제 #4
0
 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'
예제 #5
0
 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'