protected function writeImpl(PhpBuf_IO_Writer_Interface $writer, $value) { $this->writeWireTypeData($writer, PhpBuf_ZigZag::encode($value)); }
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();
public function testDecodeNegativeValue() { $this->setExpectedException('PhpBuf_ZigZag_Exception'); PhpBuf_ZigZag::decode(-1); }