aboutsummaryrefslogtreecommitdiffhomepage
path: root/php/tests/php_implementation_test.php
diff options
context:
space:
mode:
authorGravatar Paul Yang <TeBoring@users.noreply.github.com>2017-02-07 21:33:28 -0800
committerGravatar Paul Yang <TeBoring@users.noreply.github.com>2017-03-15 14:16:49 -0700
commitf23869c6154d8b083ee3417fac277bc25e13a4ac (patch)
tree2e9ea1cfcc88211ac1e364155d696c808acb11ba /php/tests/php_implementation_test.php
parent014a5507fb4b1ccc12f35ff313b8a04c05d69b7f (diff)
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.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/php/tests/php_implementation_test.php b/php/tests/php_implementation_test.php
index ec6b8d5a..e1249808 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(481, $m->byteSize());
+ $this->assertSame(506, $m->byteSize());
}
public function testPackedByteSize()
{
$m = new TestPackedMessage();
TestUtil::setTestPackedMessage($m);
- $this->assertSame(156, $m->byteSize());
+ $this->assertSame(166, $m->byteSize());
}
}