Fix field mask for php in json (#5591)
* Fix field mask for php in json * Update byte size
This commit is contained in:
parent
dda7ab0363
commit
c4f2a92c55
@ -5,6 +5,7 @@ Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
|
||||
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
|
||||
Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
|
||||
Recommended.Proto3.JsonInput.Int64FieldBeString.Validator
|
||||
Recommended.Proto3.JsonInput.MapFieldValueIsNull
|
||||
Recommended.Proto3.JsonInput.OneofZeroBytes.JsonOutput
|
||||
@ -22,8 +23,6 @@ Required.DurationProtoInputTooLarge.JsonOutput
|
||||
Required.DurationProtoInputTooSmall.JsonOutput
|
||||
Required.TimestampProtoInputTooLarge.JsonOutput
|
||||
Required.TimestampProtoInputTooSmall.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithFieldMask.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithFieldMask.ProtobufOutput
|
||||
Required.Proto3.JsonInput.BoolMapField.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
|
||||
@ -32,22 +31,14 @@ Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldNan.JsonOutput
|
||||
Required.Proto3.JsonInput.DurationMinValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DurationRepeatedValue.JsonOutput
|
||||
Required.Proto3.JsonInput.FieldMask.JsonOutput
|
||||
Required.Proto3.JsonInput.FieldMask.ProtobufOutput
|
||||
Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput
|
||||
Required.Proto3.JsonInput.FloatFieldNan.JsonOutput
|
||||
Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput
|
||||
Required.Proto3.JsonInput.OneofFieldDuplicate
|
||||
Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.StringFieldEscape.JsonOutput
|
||||
Required.Proto3.JsonInput.StringFieldEscape.ProtobufOutput
|
||||
Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput
|
||||
Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput
|
||||
Required.Proto3.JsonInput.StringFieldUnicodeEscape.JsonOutput
|
||||
Required.Proto3.JsonInput.StringFieldUnicodeEscape.ProtobufOutput
|
||||
Required.Proto3.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput
|
||||
Required.Proto3.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput
|
||||
Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
|
||||
Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
|
||||
Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
|
||||
|
@ -148,6 +148,11 @@ static const void* newhandlerdata(upb_handlers* h, uint32_t ofs) {
|
||||
return hd_ofs;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
void* closure;
|
||||
stringsink sink;
|
||||
} stringfields_parseframe_t;
|
||||
|
||||
typedef size_t (*encodeunknown_handlerfunc)(void* _sink, const void* hd,
|
||||
const char* ptr, size_t len,
|
||||
const upb_bufhandle* handle);
|
||||
@ -245,46 +250,41 @@ DEFINE_APPEND_HANDLER(int64, int64_t)
|
||||
DEFINE_APPEND_HANDLER(uint64, uint64_t)
|
||||
DEFINE_APPEND_HANDLER(double, double)
|
||||
|
||||
// Appends a string to a repeated field.
|
||||
// Appends a string or 'bytes' string to a repeated field.
|
||||
static void* appendstr_handler(void *closure,
|
||||
const void *hd,
|
||||
size_t size_hint) {
|
||||
zval* array = (zval*)closure;
|
||||
TSRMLS_FETCH();
|
||||
RepeatedField* intern = UNBOX(RepeatedField, array);
|
||||
UPB_UNUSED(hd);
|
||||
|
||||
#if PHP_MAJOR_VERSION < 7
|
||||
zval* str;
|
||||
MAKE_STD_ZVAL(str);
|
||||
PHP_PROTO_ZVAL_STRING(str, "", 1);
|
||||
repeated_field_push_native(intern, &str);
|
||||
return (void*)str;
|
||||
#else
|
||||
zend_string* str = zend_string_init("", 0, 1);
|
||||
repeated_field_push_native(intern, &str);
|
||||
return intern;
|
||||
#endif
|
||||
stringfields_parseframe_t* frame =
|
||||
(stringfields_parseframe_t*)malloc(sizeof(stringfields_parseframe_t));
|
||||
frame->closure = closure;
|
||||
stringsink_init(&frame->sink);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
// Appends a 'bytes' string to a repeated field.
|
||||
static void* appendbytes_handler(void *closure,
|
||||
const void *hd,
|
||||
size_t size_hint) {
|
||||
zval* array = (zval*)closure;
|
||||
static bool appendstr_end_handler(void *closure, const void *hd) {
|
||||
stringfields_parseframe_t* frame = closure;
|
||||
|
||||
zval* array = (zval*)frame->closure;
|
||||
TSRMLS_FETCH();
|
||||
RepeatedField* intern = UNBOX(RepeatedField, array);
|
||||
|
||||
#if PHP_MAJOR_VERSION < 7
|
||||
zval* str;
|
||||
MAKE_STD_ZVAL(str);
|
||||
PHP_PROTO_ZVAL_STRING(str, "", 1);
|
||||
PHP_PROTO_ZVAL_STRINGL(str, frame->sink.ptr, frame->sink.len, 1);
|
||||
repeated_field_push_native(intern, &str);
|
||||
return (void*)str;
|
||||
#else
|
||||
zend_string* str = zend_string_init("", 0, 1);
|
||||
zend_string* str = zend_string_init(frame->sink.ptr, frame->sink.len, 1);
|
||||
repeated_field_push_native(intern, &str);
|
||||
return intern;
|
||||
#endif
|
||||
|
||||
stringsink_uninit(&frame->sink);
|
||||
free(frame);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Handlers that append primitive values to a repeated field.
|
||||
@ -326,64 +326,76 @@ static void *empty_php_string(zval* value_ptr) {
|
||||
return value_ptr;
|
||||
}
|
||||
#endif
|
||||
#if PHP_MAJOR_VERSION < 7
|
||||
static void *empty_php_string2(zval** value_ptr) {
|
||||
SEPARATE_ZVAL_IF_NOT_REF(value_ptr);
|
||||
if (Z_TYPE_PP(value_ptr) == IS_STRING &&
|
||||
!IS_INTERNED(Z_STRVAL_PP(value_ptr))) {
|
||||
FREE(Z_STRVAL_PP(value_ptr));
|
||||
}
|
||||
ZVAL_EMPTY_STRING(*value_ptr);
|
||||
return (void*)(*value_ptr);
|
||||
}
|
||||
static void new_php_string(zval** value_ptr, const char* str, size_t len) {
|
||||
SEPARATE_ZVAL_IF_NOT_REF(value_ptr);
|
||||
if (Z_TYPE_PP(value_ptr) == IS_STRING &&
|
||||
!IS_INTERNED(Z_STRVAL_PP(value_ptr))) {
|
||||
FREE(Z_STRVAL_PP(value_ptr));
|
||||
}
|
||||
ZVAL_EMPTY_STRING(*value_ptr);
|
||||
ZVAL_STRINGL(*value_ptr, str, len, 1);
|
||||
}
|
||||
#else
|
||||
static void *empty_php_string2(zval* value_ptr) {
|
||||
if (Z_TYPE_P(value_ptr) == IS_STRING) {
|
||||
zend_string_release(Z_STR_P(value_ptr));
|
||||
}
|
||||
ZVAL_EMPTY_STRING(value_ptr);
|
||||
return value_ptr;
|
||||
}
|
||||
static void new_php_string(zval* value_ptr, const char* str, size_t len) {
|
||||
if (Z_TYPE_P(value_ptr) == IS_STRING) {
|
||||
zend_string_release(Z_STR_P(value_ptr));
|
||||
}
|
||||
ZVAL_NEW_STR(value_ptr, zend_string_init(str, len, 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Sets a non-repeated string field in a message.
|
||||
// Sets a non-repeated string/bytes field in a message.
|
||||
static void* str_handler(void *closure,
|
||||
const void *hd,
|
||||
size_t size_hint) {
|
||||
MessageHeader* msg = closure;
|
||||
const size_t *ofs = hd;
|
||||
return empty_php_string(DEREF(message_data(msg), *ofs, CACHED_VALUE*));
|
||||
UPB_UNUSED(hd);
|
||||
|
||||
stringfields_parseframe_t* frame =
|
||||
(stringfields_parseframe_t*)malloc(sizeof(stringfields_parseframe_t));
|
||||
frame->closure = closure;
|
||||
stringsink_init(&frame->sink);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
// Sets a non-repeated 'bytes' field in a message.
|
||||
static void* bytes_handler(void *closure,
|
||||
const void *hd,
|
||||
size_t size_hint) {
|
||||
MessageHeader* msg = closure;
|
||||
static bool str_end_handler(void *closure, const void *hd) {
|
||||
stringfields_parseframe_t* frame = closure;
|
||||
const size_t *ofs = hd;
|
||||
return empty_php_string(DEREF(message_data(msg), *ofs, CACHED_VALUE*));
|
||||
MessageHeader* msg = (MessageHeader*)frame->closure;
|
||||
|
||||
new_php_string(DEREF(message_data(msg), *ofs, CACHED_VALUE*),
|
||||
frame->sink.ptr, frame->sink.len);
|
||||
|
||||
stringsink_uninit(&frame->sink);
|
||||
free(frame);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static size_t stringdata_handler(void* closure, const void* hd,
|
||||
const char* str, size_t len,
|
||||
const upb_bufhandle* handle) {
|
||||
zval* php_str = (zval*)closure;
|
||||
#if PHP_MAJOR_VERSION < 7
|
||||
// Oneof string/bytes fields may have NULL initial value, which doesn't need
|
||||
// to be freed.
|
||||
if (Z_TYPE_P(php_str) == IS_STRING && !IS_INTERNED(Z_STRVAL_P(php_str))) {
|
||||
FREE(Z_STRVAL_P(php_str));
|
||||
}
|
||||
ZVAL_STRINGL(php_str, str, len, 1);
|
||||
#else
|
||||
if (Z_TYPE_P(php_str) == IS_STRING) {
|
||||
zend_string_release(Z_STR_P(php_str));
|
||||
}
|
||||
ZVAL_NEW_STR(php_str, zend_string_init(str, len, 0));
|
||||
#endif
|
||||
return len;
|
||||
stringfields_parseframe_t* frame = closure;
|
||||
return stringsink_string(&frame->sink, hd, str, len, handle);
|
||||
}
|
||||
|
||||
#if PHP_MAJOR_VERSION >= 7
|
||||
static size_t zendstringdata_handler(void* closure, const void* hd,
|
||||
const char* str, size_t len,
|
||||
const upb_bufhandle* handle) {
|
||||
RepeatedField* intern = (RepeatedField*)closure;
|
||||
|
||||
unsigned char memory[NATIVE_SLOT_MAX_SIZE];
|
||||
memset(memory, 0, NATIVE_SLOT_MAX_SIZE);
|
||||
*(zend_string**)memory = zend_string_init(str, len, 0);
|
||||
|
||||
HashTable *ht = PHP_PROTO_HASH_OF(intern->array);
|
||||
int index = zend_hash_num_elements(ht) - 1;
|
||||
php_proto_zend_hash_index_update_mem(
|
||||
ht, index, memory, sizeof(zend_string*), NULL);
|
||||
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Appends a submessage to a repeated field.
|
||||
static void *appendsubmsg_handler(void *closure, const void *hd) {
|
||||
zval* array = (zval*)closure;
|
||||
@ -744,13 +756,38 @@ static void *oneofbytes_handler(void *closure,
|
||||
return empty_php_string(DEREF(
|
||||
message_data(msg), oneofdata->ofs, CACHED_VALUE*));
|
||||
}
|
||||
static bool oneofstr_end_handler(void *closure, const void *hd) {
|
||||
stringfields_parseframe_t* frame = closure;
|
||||
MessageHeader* msg = (MessageHeader*)frame->closure;
|
||||
const oneof_handlerdata_t *oneofdata = hd;
|
||||
|
||||
oneof_cleanup(msg, oneofdata);
|
||||
|
||||
DEREF(message_data(msg), oneofdata->case_ofs, uint32_t) =
|
||||
oneofdata->oneof_case_num;
|
||||
DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*) =
|
||||
OBJ_PROP(&msg->std, oneofdata->property_ofs);
|
||||
|
||||
new_php_string(DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*),
|
||||
frame->sink.ptr, frame->sink.len);
|
||||
|
||||
stringsink_uninit(&frame->sink);
|
||||
free(frame);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void *oneofstr_handler(void *closure,
|
||||
const void *hd,
|
||||
size_t size_hint) {
|
||||
// TODO(teboring): Add it back.
|
||||
// rb_enc_associate(str, kRubyString8bitEncoding);
|
||||
return oneofbytes_handler(closure, hd, size_hint);
|
||||
UPB_UNUSED(hd);
|
||||
|
||||
stringfields_parseframe_t* frame =
|
||||
(stringfields_parseframe_t*)malloc(sizeof(stringfields_parseframe_t));
|
||||
frame->closure = closure;
|
||||
stringsink_init(&frame->sink);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
// Handler for a submessage field in a oneof.
|
||||
@ -822,15 +859,9 @@ static void add_handlers_for_repeated_field(upb_handlers *h,
|
||||
|
||||
case UPB_TYPE_STRING:
|
||||
case UPB_TYPE_BYTES: {
|
||||
bool is_bytes = upb_fielddef_type(f) == UPB_TYPE_BYTES;
|
||||
upb_handlers_setstartstr(h, f, is_bytes ?
|
||||
appendbytes_handler : appendstr_handler,
|
||||
NULL);
|
||||
#if PHP_MAJOR_VERSION < 7
|
||||
upb_handlers_setstartstr(h, f, appendstr_handler, NULL);
|
||||
upb_handlers_setstring(h, f, stringdata_handler, NULL);
|
||||
#else
|
||||
upb_handlers_setstring(h, f, zendstringdata_handler, NULL);
|
||||
#endif
|
||||
upb_handlers_setendstr(h, f, appendstr_end_handler, &attr);
|
||||
break;
|
||||
}
|
||||
case UPB_TYPE_MESSAGE: {
|
||||
@ -870,13 +901,11 @@ static void add_handlers_for_singular_field(upb_handlers *h,
|
||||
|
||||
case UPB_TYPE_STRING:
|
||||
case UPB_TYPE_BYTES: {
|
||||
bool is_bytes = upb_fielddef_type(f) == UPB_TYPE_BYTES;
|
||||
upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER;
|
||||
upb_handlerattr_sethandlerdata(&attr, newhandlerdata(h, offset));
|
||||
upb_handlers_setstartstr(h, f,
|
||||
is_bytes ? bytes_handler : str_handler,
|
||||
&attr);
|
||||
upb_handlers_setstartstr(h, f, str_handler, &attr);
|
||||
upb_handlers_setstring(h, f, stringdata_handler, &attr);
|
||||
upb_handlers_setendstr(h, f, str_end_handler, &attr);
|
||||
upb_handlerattr_uninit(&attr);
|
||||
break;
|
||||
}
|
||||
@ -958,11 +987,9 @@ static void add_handlers_for_oneof_field(upb_handlers *h,
|
||||
|
||||
case UPB_TYPE_STRING:
|
||||
case UPB_TYPE_BYTES: {
|
||||
bool is_bytes = upb_fielddef_type(f) == UPB_TYPE_BYTES;
|
||||
upb_handlers_setstartstr(h, f, is_bytes ?
|
||||
oneofbytes_handler : oneofstr_handler,
|
||||
&attr);
|
||||
upb_handlers_setstartstr(h, f, oneofstr_handler, &attr);
|
||||
upb_handlers_setstring(h, f, stringdata_handler, NULL);
|
||||
upb_handlers_setendstr(h, f, oneofstr_end_handler, &attr);
|
||||
break;
|
||||
}
|
||||
case UPB_TYPE_MESSAGE: {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2014,6 +2014,7 @@ typedef enum {
|
||||
typedef enum {
|
||||
UPB_WELLKNOWN_UNSPECIFIED,
|
||||
UPB_WELLKNOWN_ANY,
|
||||
UPB_WELLKNOWN_FIELDMASK,
|
||||
UPB_WELLKNOWN_DURATION,
|
||||
UPB_WELLKNOWN_TIMESTAMP,
|
||||
/* number wrappers */
|
||||
|
@ -14,6 +14,7 @@ use Foo\TestRandomFieldOrder;
|
||||
use Foo\TestUnpackedMessage;
|
||||
use Google\Protobuf\Any;
|
||||
use Google\Protobuf\DoubleValue;
|
||||
use Google\Protobuf\FieldMask;
|
||||
use Google\Protobuf\FloatValue;
|
||||
use Google\Protobuf\Int32Value;
|
||||
use Google\Protobuf\UInt32Value;
|
||||
@ -266,6 +267,40 @@ class EncodeDecodeTest extends TestBase
|
||||
|
||||
}
|
||||
|
||||
public function testJsonEncodeDecodeOneof()
|
||||
{
|
||||
$m = new TestMessage();
|
||||
|
||||
$m->setOneofEnum(TestEnum::ONE);
|
||||
$data = $m->serializeToJsonString();
|
||||
$n = new TestMessage();
|
||||
$n->mergeFromJsonString($data);
|
||||
$this->assertSame("oneof_enum", $n->getMyOneof());
|
||||
$this->assertSame(TestEnum::ONE, $n->getOneofEnum());
|
||||
|
||||
$m->setOneofString("a");
|
||||
$data = $m->serializeToJsonString();
|
||||
$n = new TestMessage();
|
||||
$n->mergeFromJsonString($data);
|
||||
$this->assertSame("oneof_string", $n->getMyOneof());
|
||||
$this->assertSame("a", $n->getOneofString());
|
||||
|
||||
$m->setOneofBytes("bbbb");
|
||||
$data = $m->serializeToJsonString();
|
||||
$n = new TestMessage();
|
||||
$n->mergeFromJsonString($data);
|
||||
$this->assertSame("oneof_bytes", $n->getMyOneof());
|
||||
$this->assertSame("bbbb", $n->getOneofBytes());
|
||||
|
||||
$sub_m = new Sub();
|
||||
$m->setOneofMessage($sub_m);
|
||||
$data = $m->serializeToJsonString();
|
||||
$n = new TestMessage();
|
||||
$n->mergeFromJsonString($data);
|
||||
$this->assertSame("oneof_message", $n->getMyOneof());
|
||||
$this->assertFalse(is_null($n->getOneofMessage()));
|
||||
}
|
||||
|
||||
public function testPackedEncode()
|
||||
{
|
||||
$from = new TestPackedMessage();
|
||||
@ -1070,4 +1105,27 @@ class EncodeDecodeTest extends TestBase
|
||||
$m->serializeToJsonString());
|
||||
}
|
||||
|
||||
public function testDecodeTopLevelFieldMask()
|
||||
{
|
||||
$m = new TestMessage();
|
||||
$m->setMapStringString(['a'=>'abcdefg']);
|
||||
$data1 = $m->serializeToJsonString();
|
||||
$n = new TestMessage();
|
||||
$n->mergeFromJsonString($data1);
|
||||
$data2 = $n->serializeToJsonString();
|
||||
$this->assertSame($data1, $data2);
|
||||
|
||||
$m = new FieldMask();
|
||||
$m->mergeFromJsonString("\"foo.barBaz,qux\"");
|
||||
$this->assertSame("foo.bar_baz", $m->getPaths()[0]);
|
||||
$this->assertSame("qux", $m->getPaths()[1]);
|
||||
}
|
||||
|
||||
public function testEncodeTopLevelFieldMask()
|
||||
{
|
||||
$m = new FieldMask();
|
||||
$m->setPaths(["foo.bar_baz", "qux"]);
|
||||
$this->assertSame("\"foo.barBaz,qux\"", $m->serializeToJsonString());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1329,7 +1329,7 @@ class GeneratedClassTest extends TestBase
|
||||
'optional_double' => 1.6,
|
||||
'optional_bool' => true,
|
||||
'optional_string' => 'a',
|
||||
'optional_bytes' => 'b',
|
||||
'optional_bytes' => 'bbbb',
|
||||
'optional_enum' => TestEnum::ONE,
|
||||
'optional_message' => new Sub([
|
||||
'a' => 33
|
||||
@ -1348,7 +1348,7 @@ class GeneratedClassTest extends TestBase
|
||||
'repeated_double' => [1.6, 2.6],
|
||||
'repeated_bool' => [true, false],
|
||||
'repeated_string' => ['a', 'c'],
|
||||
'repeated_bytes' => ['b', 'd'],
|
||||
'repeated_bytes' => ['bbbb', 'dddd'],
|
||||
'repeated_enum' => [TestEnum::ZERO, TestEnum::ONE],
|
||||
'repeated_message' => [new Sub(['a' => 34]),
|
||||
new Sub(['a' => 35])],
|
||||
@ -1366,7 +1366,7 @@ class GeneratedClassTest extends TestBase
|
||||
'map_int32_double' => [1 => 3.6],
|
||||
'map_bool_bool' => [true => true],
|
||||
'map_string_string' => ['e' => 'e'],
|
||||
'map_int32_bytes' => [1 => 'f'],
|
||||
'map_int32_bytes' => [1 => 'ffff'],
|
||||
'map_int32_enum' => [1 => TestEnum::ONE],
|
||||
'map_int32_message' => [1 => new Sub(['a' => 36])],
|
||||
]);
|
||||
|
@ -504,7 +504,7 @@ class ImplementationTest extends TestBase
|
||||
{
|
||||
$m = new TestMessage();
|
||||
TestUtil::setTestMessage($m);
|
||||
$this->assertSame(506, $m->byteSize());
|
||||
$this->assertSame(518, $m->byteSize());
|
||||
}
|
||||
|
||||
public function testPackedByteSize()
|
||||
|
@ -28,7 +28,7 @@ class TestBase extends \PHPUnit\Framework\TestCase
|
||||
$this->assertSame(1.6, $m->getOptionalDouble());
|
||||
$this->assertSame(true, $m->getOptionalBool());
|
||||
$this->assertSame('a', $m->getOptionalString());
|
||||
$this->assertSame('b', $m->getOptionalBytes());
|
||||
$this->assertSame('bbbb', $m->getOptionalBytes());
|
||||
$this->assertSame(TestEnum::ONE, $m->getOptionalEnum());
|
||||
$this->assertSame(33, $m->getOptionalMessage()->getA());
|
||||
if (PHP_INT_SIZE == 4) {
|
||||
@ -59,7 +59,7 @@ class TestBase extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals(1.6, $m->getRepeatedDouble()[0]);
|
||||
$this->assertEquals(true, $m->getRepeatedBool()[0]);
|
||||
$this->assertEquals('a', $m->getRepeatedString()[0]);
|
||||
$this->assertEquals('b', $m->getRepeatedBytes()[0]);
|
||||
$this->assertEquals('bbbb', $m->getRepeatedBytes()[0]);
|
||||
$this->assertEquals(34, $m->getRepeatedMessage()[0]->GetA());
|
||||
|
||||
$this->assertEquals(-52, $m->getRepeatedInt32()[1]);
|
||||
@ -76,7 +76,7 @@ class TestBase extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals(2.6, $m->getRepeatedDouble()[1]);
|
||||
$this->assertEquals(false, $m->getRepeatedBool()[1]);
|
||||
$this->assertEquals('c', $m->getRepeatedString()[1]);
|
||||
$this->assertEquals('d', $m->getRepeatedBytes()[1]);
|
||||
$this->assertEquals('dddd', $m->getRepeatedBytes()[1]);
|
||||
$this->assertEquals(35, $m->getRepeatedMessage()[1]->GetA());
|
||||
|
||||
if (PHP_INT_SIZE == 4) {
|
||||
@ -101,7 +101,7 @@ class TestBase extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals(3.6, $m->getMapInt32Double()[1]);
|
||||
$this->assertEquals(true , $m->getMapBoolBool()[true]);
|
||||
$this->assertEquals('e', $m->getMapStringString()['e']);
|
||||
$this->assertEquals('f', $m->getMapInt32Bytes()[1]);
|
||||
$this->assertEquals('ffff', $m->getMapInt32Bytes()[1]);
|
||||
$this->assertEquals(TestEnum::ONE, $m->getMapInt32Enum()[1]);
|
||||
$this->assertEquals(36, $m->getMapInt32Message()[1]->GetA());
|
||||
}
|
||||
@ -146,7 +146,7 @@ class TestBase extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals(1.6, $m->getRepeatedDouble()[0]);
|
||||
$this->assertEquals(true, $m->getRepeatedBool()[0]);
|
||||
$this->assertEquals('a', $m->getRepeatedString()[0]);
|
||||
$this->assertEquals('b', $m->getRepeatedBytes()[0]);
|
||||
$this->assertEquals('bbbb', $m->getRepeatedBytes()[0]);
|
||||
$this->assertEquals(TestEnum::ZERO, $m->getRepeatedEnum()[0]);
|
||||
$this->assertEquals(34, $m->getRepeatedMessage()[0]->GetA());
|
||||
|
||||
@ -164,7 +164,7 @@ class TestBase extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals(2.6, $m->getRepeatedDouble()[1]);
|
||||
$this->assertEquals(false, $m->getRepeatedBool()[1]);
|
||||
$this->assertEquals('c', $m->getRepeatedString()[1]);
|
||||
$this->assertEquals('d', $m->getRepeatedBytes()[1]);
|
||||
$this->assertEquals('dddd', $m->getRepeatedBytes()[1]);
|
||||
$this->assertEquals(TestEnum::ONE, $m->getRepeatedEnum()[1]);
|
||||
$this->assertEquals(35, $m->getRepeatedMessage()[1]->GetA());
|
||||
|
||||
|
@ -65,7 +65,7 @@ class TestUtil
|
||||
$m->setOptionalDouble(1.6);
|
||||
$m->setOptionalBool(true);
|
||||
$m->setOptionalString('a');
|
||||
$m->setOptionalBytes('b');
|
||||
$m->setOptionalBytes('bbbb');
|
||||
$m->setOptionalEnum(TestEnum::ONE);
|
||||
$sub = new Sub();
|
||||
$m->setOptionalMessage($sub);
|
||||
@ -85,7 +85,7 @@ class TestUtil
|
||||
self::appendHelper($m, 'RepeatedDouble', 1.6);
|
||||
self::appendHelper($m, 'RepeatedBool', true);
|
||||
self::appendHelper($m, 'RepeatedString', 'a');
|
||||
self::appendHelper($m, 'RepeatedBytes', 'b');
|
||||
self::appendHelper($m, 'RepeatedBytes', 'bbbb');
|
||||
self::appendHelper($m, 'RepeatedEnum', TestEnum::ZERO);
|
||||
self::appendHelper($m, 'RepeatedMessage', new Sub());
|
||||
$m->getRepeatedMessage()[0]->setA(34);
|
||||
@ -104,7 +104,7 @@ class TestUtil
|
||||
self::appendHelper($m, 'RepeatedDouble', 2.6);
|
||||
self::appendHelper($m, 'RepeatedBool', false);
|
||||
self::appendHelper($m, 'RepeatedString', 'c');
|
||||
self::appendHelper($m, 'RepeatedBytes', 'd');
|
||||
self::appendHelper($m, 'RepeatedBytes', 'dddd');
|
||||
self::appendHelper($m, 'RepeatedEnum', TestEnum::ONE);
|
||||
self::appendHelper($m, 'RepeatedMessage', new Sub());
|
||||
$m->getRepeatedMessage()[1]->SetA(35);
|
||||
@ -123,7 +123,7 @@ class TestUtil
|
||||
self::kvUpdateHelper($m, 'MapInt32Double', 1, 3.6);
|
||||
self::kvUpdateHelper($m, 'MapBoolBool', true, true);
|
||||
self::kvUpdateHelper($m, 'MapStringString', 'e', 'e');
|
||||
self::kvUpdateHelper($m, 'MapInt32Bytes', 1, 'f');
|
||||
self::kvUpdateHelper($m, 'MapInt32Bytes', 1, 'ffff');
|
||||
self::kvUpdateHelper($m, 'MapInt32Enum', 1, TestEnum::ONE);
|
||||
self::kvUpdateHelper($m, 'MapInt32Message', 1, new Sub());
|
||||
$m->getMapInt32Message()[1]->SetA(36);
|
||||
@ -234,7 +234,7 @@ class TestUtil
|
||||
assert(1.6 === $m->getOptionalDouble());
|
||||
assert(true=== $m->getOptionalBool());
|
||||
assert('a' === $m->getOptionalString());
|
||||
assert('b' === $m->getOptionalBytes());
|
||||
assert('bbbb' === $m->getOptionalBytes());
|
||||
assert(TestEnum::ONE === $m->getOptionalEnum());
|
||||
assert(33 === $m->getOptionalMessage()->getA());
|
||||
|
||||
@ -260,7 +260,7 @@ class TestUtil
|
||||
assert(1.6 === $m->getRepeatedDouble()[0]);
|
||||
assert(true=== $m->getRepeatedBool()[0]);
|
||||
assert('a' === $m->getRepeatedString()[0]);
|
||||
assert('b' === $m->getRepeatedBytes()[0]);
|
||||
assert('bbbb' === $m->getRepeatedBytes()[0]);
|
||||
assert(TestEnum::ZERO === $m->getRepeatedEnum()[0]);
|
||||
assert(34 === $m->getRepeatedMessage()[0]->getA());
|
||||
|
||||
@ -286,7 +286,7 @@ class TestUtil
|
||||
assert(2.6 === $m->getRepeatedDouble()[1]);
|
||||
assert(false === $m->getRepeatedBool()[1]);
|
||||
assert('c' === $m->getRepeatedString()[1]);
|
||||
assert('d' === $m->getRepeatedBytes()[1]);
|
||||
assert('dddd' === $m->getRepeatedBytes()[1]);
|
||||
assert(TestEnum::ONE === $m->getRepeatedEnum()[1]);
|
||||
assert(35 === $m->getRepeatedMessage()[1]->getA());
|
||||
|
||||
@ -312,7 +312,7 @@ class TestUtil
|
||||
assert(3.6 === $m->getMapInt32Double()[1]);
|
||||
assert(true === $m->getMapBoolBool()[true]);
|
||||
assert('e' === $m->getMapStringString()['e']);
|
||||
assert('f' === $m->getMapInt32Bytes()[1]);
|
||||
assert('ffff' === $m->getMapInt32Bytes()[1]);
|
||||
assert(TestEnum::ONE === $m->getMapInt32Enum()[1]);
|
||||
assert(36 === $m->getMapInt32Message()[1]->GetA());
|
||||
}
|
||||
@ -334,7 +334,7 @@ class TestUtil
|
||||
"619A9999999999F93F" .
|
||||
"6801" .
|
||||
"720161" .
|
||||
"7A0162" .
|
||||
"7A0462626262" .
|
||||
"800101" .
|
||||
"8A01020821" .
|
||||
|
||||
@ -366,8 +366,8 @@ class TestUtil
|
||||
"D80200" .
|
||||
"E2020161" .
|
||||
"E2020163" .
|
||||
"EA020162" .
|
||||
"EA020164" .
|
||||
"EA020462626262" .
|
||||
"EA020464646464" .
|
||||
"F00200" .
|
||||
"F00201" .
|
||||
"FA02020822" .
|
||||
@ -387,7 +387,7 @@ class TestUtil
|
||||
"92050B080111CDCCCCCCCCCC0C40" .
|
||||
"9A050408011001" .
|
||||
"A205060a0165120165" .
|
||||
"AA05050801120166" .
|
||||
"AA05080801120466666666" .
|
||||
"B2050408011001" .
|
||||
"Ba0506080112020824"
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user