コード例 #1
0
ファイル: test_base.php プロジェクト: slavanap/protobuf
 public function setFields(TestMessage $m)
 {
     TestUtil::setTestMessage($m);
 }
コード例 #2
0
<?php

# phpunit has memory leak by itself. Thus, it cannot be used to test memory leak.
require_once 'test.pb.php';
require_once 'test_util.php';
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBType;
use Foo\TestMessage;
use Foo\TestMessage_Sub;
$from = new TestMessage();
TestUtil::setTestMessage($from);
TestUtil::assertTestMessage($from);
$data = $from->encode();
$to = new TestMessage();
$to->decode($data);
TestUtil::assertTestMessage($to);
$from->setRecursive($from);
$arr = new RepeatedField(GPBType::MESSAGE, TestMessage::class);
$arr[] = new TestMessage();
$arr[0]->SetRepeatedRecursive($arr);
// Test oneof fields.
$m = new TestMessage();
$m->setOneofInt32(1);
assert(1 === $m->getOneofInt32());
assert(0.0 === $m->getOneofFloat());
assert('' === $m->getOneofString());
assert(NULL === $m->getOneofMessage());
$data = $m->encode();
$n = new TestMessage();
$n->decode($data);
assert(1 === $n->getOneofInt32());
コード例 #3
0
 public function testByteSize()
 {
     $m = new TestMessage();
     TestUtil::setTestMessage($m);
     $this->assertSame(447, $m->byteSize());
 }