aboutsummaryrefslogtreecommitdiff
path: root/php/tests/encode_decode_test.php
diff options
context:
space:
mode:
Diffstat (limited to 'php/tests/encode_decode_test.php')
-rw-r--r--php/tests/encode_decode_test.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/php/tests/encode_decode_test.php b/php/tests/encode_decode_test.php
index 992f1631..dfe3b353 100644
--- a/php/tests/encode_decode_test.php
+++ b/php/tests/encode_decode_test.php
@@ -22,7 +22,8 @@ class EncodeDecodeTest extends TestBase
$this->expectFields($from);
$data = $from->encode();
- $this->assertSame(TestUtil::getGoldenTestMessage(), $data);
+ $this->assertSame(bin2hex(TestUtil::getGoldenTestMessage()),
+ bin2hex($data));
}
public function testDecode()
@@ -173,4 +174,25 @@ class EncodeDecodeTest extends TestBase
$m = new TestMessage();
$m->decode($data);
}
+
+ public function testEncodeNegativeInt32()
+ {
+ $m = new TestMessage();
+ $m->setOptionalInt32(-1);
+ $data = $m->encode();
+ $this->assertSame("08ffffffffffffffffff01", bin2hex($data));
+ }
+
+ public function testDecodeNegativeInt32()
+ {
+ $m = new TestMessage();
+ $this->assertEquals(0, $m->getOptionalInt32());
+ $m->decode(hex2bin("08ffffffffffffffffff01"));
+ $this->assertEquals(-1, $m->getOptionalInt32());
+
+ $m = new TestMessage();
+ $this->assertEquals(0, $m->getOptionalInt32());
+ $m->decode(hex2bin("08ffffffff0f"));
+ $this->assertEquals(-1, $m->getOptionalInt32());
+ }
}