diff options
author | Paul Yang <TeBoring@users.noreply.github.com> | 2017-02-07 21:33:28 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-07 21:33:28 -0800 |
commit | 2edf2bdebf1ede582b816a521ad6e51a802eaa46 (patch) | |
tree | d1a408c6ea5a3c32306864d1b96d7708bdb0e120 /php/tests/php_implementation_test.php | |
parent | c7f4c7bc417a24eeb7d5ac10a91b85b2df8a0b41 (diff) | |
download | protobuf-2edf2bdebf1ede582b816a521ad6e51a802eaa46.tar.gz protobuf-2edf2bdebf1ede582b816a521ad6e51a802eaa46.tar.bz2 protobuf-2edf2bdebf1ede582b816a521ad6e51a802eaa46.zip |
Bug fix: When encoding, negative int32 values should be padded to int64 (#2660)
in order to be wire compatible.
Diffstat (limited to 'php/tests/php_implementation_test.php')
-rw-r--r-- | php/tests/php_implementation_test.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/php/tests/php_implementation_test.php b/php/tests/php_implementation_test.php index ac7c13dc..46d3e5b6 100644 --- a/php/tests/php_implementation_test.php +++ b/php/tests/php_implementation_test.php @@ -469,6 +469,11 @@ class ImplementationTest extends TestBase $output = new OutputStream(3); $output->writeVarint32(16384); $this->assertSame(hex2bin('808001'), $output->getData()); + + // Negative numbers are padded to be compatible with int64. + $output = new OutputStream(10); + $output->writeVarint32(-43); + $this->assertSame(hex2bin('D5FFFFFFFFFFFFFFFF01'), $output->getData()); } public function testWriteVarint64() @@ -496,13 +501,13 @@ class ImplementationTest extends TestBase { $m = new TestMessage(); TestUtil::setTestMessage($m); - $this->assertSame(447, $m->byteSize()); + $this->assertSame(472, $m->byteSize()); } public function testPackedByteSize() { $m = new TestPackedMessage(); TestUtil::setTestPackedMessage($m); - $this->assertSame(156, $m->byteSize()); + $this->assertSame(166, $m->byteSize()); } } |