Beispiel #1
0
 protected function readImpl(PhpBuf_IO_Reader_Interface $reader)
 {
     return PhpBuf_ZigZag::decode($this->readWireTypeData($reader));
 }
Beispiel #2
0
echo "value: 1\n";
$encode = PhpBuf_ZigZag::encode(1);
echo "encoded: " . $encode . "\n";
echo "decoded: " . PhpBuf_ZigZag::decode($encode) . "\n\n";
echo "value: -1\n";
$encode = PhpBuf_ZigZag::encode(-1);
echo "encoded: " . $encode . "\n";
echo "decoded: " . PhpBuf_ZigZag::decode($encode) . "\n\n";
echo "value: 123456789\n";
$encode = PhpBuf_ZigZag::encode(123456789);
echo "encoded: " . $encode . "\n";
echo "decoded: " . PhpBuf_ZigZag::decode($encode) . "\n\n";
echo "value: -123456789\n";
$encode = PhpBuf_ZigZag::encode(-123456789);
echo "encoded: " . $encode . "\n";
echo "decoded: " . PhpBuf_ZigZag::decode($encode) . "\n\n";
echo "Test Reader & Writer\n";
$writer = new PhpBuf_IO_Writer();
$writer->writeBytes("test1");
echo "lenght: " . $writer->getLenght() . "\n";
echo "test1 = " . $writer->getData() . "\n";
$writer->writeBytes("test2");
echo "lenght: " . $writer->getLenght() . "\n";
echo "test1test2 = " . $writer->getData() . "\n";
$writer->redo();
echo "lenght: " . $writer->getLenght() . "\n";
echo "test1 = " . $writer->getData() . "\n";
$writer->writeByte("!");
echo "lenght: " . $writer->getLenght() . "\n";
echo "test1! = " . $writer->getData() . "\n";
$writer->redo();
Beispiel #3
0
 public function testDecodeNegativeValue()
 {
     $this->setExpectedException('PhpBuf_ZigZag_Exception');
     PhpBuf_ZigZag::decode(-1);
 }