/** * @dataProvider varintProvider */ public function testComputeVarintSize($value) { $stream = Stream::create(); $this->writer->writeVarint($stream, $value); $streamSize = $stream->getSize(); $actualSize = $this->calculator->computeVarintSize($value); $this->assertEquals($streamSize, $actualSize); }
public function testWriteStream() { $source = Stream::create(); $target = Stream::create(); $writer = new StreamWriter($this->config); $writer->writeVarint($source, WireFormat::getFieldKey(1, WireFormat::WIRE_FIXED64)); $writer->writeDouble($source, 123456789.12345); $source->seek(0); $writer->writeStream($target, $source); $this->assertEquals((string) $source, (string) $target); }