def write(writer: BitStreamWriter, value: str) -> None: """ Writes Zserio string type to the bit stream. :param writer: Bit stream where to write. :param value: Zserio string type to write. """ writer.writeString(value)
def testFile(self): testFilename = "BitStreamTest.bin" writer = BitStreamWriter() writer.writeBits(13, 7) writer.writeString(testFilename) writer.writeVarInt(-123456) writer.toFile(testFilename) reader = BitStreamReader.fromFile(testFilename) self.assertEqual(13, reader.readBits(7)) self.assertEqual(testFilename, reader.readString()) self.assertEqual(-123456, reader.readVarInt())
def testWriteString(self): writer = BitStreamWriter() writer.writeString("") self.assertEqual(8, writer.getBitPosition()) # length 0 self.assertEqual(b'\x00', writer.getByteArray())