示例#1
0
文件: SInt.php 项目: undr/phpbuf
 protected function writeImpl(PhpBuf_IO_Writer_Interface $writer, $value)
 {
     $this->writeWireTypeData($writer, PhpBuf_ZigZag::encode($value));
 }
示例#2
0
文件: test.php 项目: undr/phpbuf
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();
示例#3
0
 public function testDecodeNegativeValue()
 {
     $this->setExpectedException('PhpBuf_ZigZag_Exception');
     PhpBuf_ZigZag::decode(-1);
 }