1ffe3c632Sopenharmony_ci<?php 2ffe3c632Sopenharmony_ci 3ffe3c632Sopenharmony_ciuse Foo\TestEnum; 4ffe3c632Sopenharmony_ciuse Foo\TestMessage; 5ffe3c632Sopenharmony_ciuse Foo\TestMessage\Sub; 6ffe3c632Sopenharmony_ciuse Foo\TestPackedMessage; 7ffe3c632Sopenharmony_ciuse Foo\TestUnpackedMessage; 8ffe3c632Sopenharmony_ci 9ffe3c632Sopenharmony_cidefine('MAX_FLOAT_DIFF', 0.000001); 10ffe3c632Sopenharmony_ci 11ffe3c632Sopenharmony_ciif (PHP_INT_SIZE == 8) { 12ffe3c632Sopenharmony_ci define('MAX_INT_STRING', '9223372036854775807'); 13ffe3c632Sopenharmony_ci define('MAX_INT_UPPER_STRING', '9223372036854775808'); 14ffe3c632Sopenharmony_ci} else { 15ffe3c632Sopenharmony_ci define('MAX_INT_STRING', '2147483647'); 16ffe3c632Sopenharmony_ci define('MAX_INT_UPPER_STRING', '2147483648'); 17ffe3c632Sopenharmony_ci} 18ffe3c632Sopenharmony_ci 19ffe3c632Sopenharmony_cidefine('MAX_INT32', 2147483647); 20ffe3c632Sopenharmony_cidefine('MAX_INT32_FLOAT', 2147483647.0); 21ffe3c632Sopenharmony_cidefine('MAX_INT32_STRING', '2147483647'); 22ffe3c632Sopenharmony_ci 23ffe3c632Sopenharmony_cidefine('MIN_INT32', (int)-2147483648); 24ffe3c632Sopenharmony_cidefine('MIN_INT32_FLOAT', -2147483648.0); 25ffe3c632Sopenharmony_cidefine('MIN_INT32_STRING', '-2147483648'); 26ffe3c632Sopenharmony_ci 27ffe3c632Sopenharmony_cidefine('MAX_UINT32', 4294967295); 28ffe3c632Sopenharmony_cidefine('MAX_UINT32_FLOAT', 4294967295.0); 29ffe3c632Sopenharmony_cidefine('MAX_UINT32_STRING', '4294967295'); 30ffe3c632Sopenharmony_ci 31ffe3c632Sopenharmony_cidefine('MIN_UINT32', (int)-2147483648); 32ffe3c632Sopenharmony_cidefine('MIN_UINT32_FLOAT', -2147483648.0); 33ffe3c632Sopenharmony_cidefine('MIN_UINT32_STRING', '-2147483648'); 34ffe3c632Sopenharmony_ci 35ffe3c632Sopenharmony_cidefine('MAX_INT64_STRING', '9223372036854775807'); 36ffe3c632Sopenharmony_cidefine('MIN_INT64_STRING', '-9223372036854775808'); 37ffe3c632Sopenharmony_cidefine('MAX_UINT64_STRING', '-9223372036854775808'); 38ffe3c632Sopenharmony_ci 39ffe3c632Sopenharmony_ciif (PHP_INT_SIZE === 8) { 40ffe3c632Sopenharmony_ci define('MAX_INT64', (int)9223372036854775807); 41ffe3c632Sopenharmony_ci define('MIN_INT64', (int)-9223372036854775808); 42ffe3c632Sopenharmony_ci define('MAX_UINT64', (int)-9223372036854775808); 43ffe3c632Sopenharmony_ci} else { 44ffe3c632Sopenharmony_ci define('MAX_INT64', MAX_INT64_STRING); 45ffe3c632Sopenharmony_ci define('MIN_INT64', MIN_INT64_STRING); 46ffe3c632Sopenharmony_ci define('MAX_UINT64', MAX_UINT64_STRING); 47ffe3c632Sopenharmony_ci} 48ffe3c632Sopenharmony_ci 49ffe3c632Sopenharmony_ciclass TestUtil 50ffe3c632Sopenharmony_ci{ 51ffe3c632Sopenharmony_ci 52ffe3c632Sopenharmony_ci public static function setTestMessage(TestMessage $m) 53ffe3c632Sopenharmony_ci { 54ffe3c632Sopenharmony_ci $m->setOptionalInt32(-42); 55ffe3c632Sopenharmony_ci $m->setOptionalInt64(-43); 56ffe3c632Sopenharmony_ci $m->setOptionalUint32(42); 57ffe3c632Sopenharmony_ci $m->setOptionalUint64(43); 58ffe3c632Sopenharmony_ci $m->setOptionalSint32(-44); 59ffe3c632Sopenharmony_ci $m->setOptionalSint64(-45); 60ffe3c632Sopenharmony_ci $m->setOptionalFixed32(46); 61ffe3c632Sopenharmony_ci $m->setOptionalFixed64(47); 62ffe3c632Sopenharmony_ci $m->setOptionalSfixed32(-46); 63ffe3c632Sopenharmony_ci $m->setOptionalSfixed64(-47); 64ffe3c632Sopenharmony_ci $m->setOptionalFloat(1.5); 65ffe3c632Sopenharmony_ci $m->setOptionalDouble(1.6); 66ffe3c632Sopenharmony_ci $m->setOptionalBool(true); 67ffe3c632Sopenharmony_ci $m->setOptionalString('a'); 68ffe3c632Sopenharmony_ci $m->setOptionalBytes('bbbb'); 69ffe3c632Sopenharmony_ci $m->setOptionalEnum(TestEnum::ONE); 70ffe3c632Sopenharmony_ci $sub = new Sub(); 71ffe3c632Sopenharmony_ci $m->setOptionalMessage($sub); 72ffe3c632Sopenharmony_ci $m->getOptionalMessage()->SetA(33); 73ffe3c632Sopenharmony_ci 74ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedInt32', -42); 75ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedInt64', -43); 76ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedUint32', 42); 77ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedUint64', 43); 78ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSint32', -44); 79ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSint64', -45); 80ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFixed32', 46); 81ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFixed64', 47); 82ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSfixed32', -46); 83ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSfixed64', -47); 84ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFloat', 1.5); 85ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedDouble', 1.6); 86ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedBool', true); 87ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedString', 'a'); 88ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedBytes', 'bbbb'); 89ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedEnum', TestEnum::ZERO); 90ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedMessage', new Sub()); 91ffe3c632Sopenharmony_ci $m->getRepeatedMessage()[0]->setA(34); 92ffe3c632Sopenharmony_ci 93ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedInt32', -52); 94ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedInt64', -53); 95ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedUint32', 52); 96ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedUint64', 53); 97ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSint32', -54); 98ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSint64', -55); 99ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFixed32', 56); 100ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFixed64', 57); 101ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSfixed32', -56); 102ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSfixed64', -57); 103ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFloat', 2.5); 104ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedDouble', 2.6); 105ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedBool', false); 106ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedString', 'c'); 107ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedBytes', 'dddd'); 108ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedEnum', TestEnum::ONE); 109ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedMessage', new Sub()); 110ffe3c632Sopenharmony_ci $m->getRepeatedMessage()[1]->SetA(35); 111ffe3c632Sopenharmony_ci 112ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Int32', -62, -62); 113ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt64Int64', -63, -63); 114ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapUint32Uint32', 62, 62); 115ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapUint64Uint64', 63, 63); 116ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapSint32Sint32', -64, -64); 117ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapSint64Sint64', -65, -65); 118ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapFixed32Fixed32', 66, 66); 119ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapFixed64Fixed64', 67, 67); 120ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapSfixed32Sfixed32', -68, -68); 121ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapSfixed64Sfixed64', -69, -69); 122ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Float', 1, 3.5); 123ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Double', 1, 3.6); 124ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapBoolBool', true, true); 125ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapStringString', 'e', 'e'); 126ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Bytes', 1, 'ffff'); 127ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Enum', 1, TestEnum::ONE); 128ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Message', 1, new Sub()); 129ffe3c632Sopenharmony_ci $m->getMapInt32Message()[1]->SetA(36); 130ffe3c632Sopenharmony_ci } 131ffe3c632Sopenharmony_ci 132ffe3c632Sopenharmony_ci public static function setTestMessage2(TestMessage $m) 133ffe3c632Sopenharmony_ci { 134ffe3c632Sopenharmony_ci $sub = new Sub(); 135ffe3c632Sopenharmony_ci 136ffe3c632Sopenharmony_ci $m->setOptionalInt32(-142); 137ffe3c632Sopenharmony_ci $m->setOptionalInt64(-143); 138ffe3c632Sopenharmony_ci $m->setOptionalUint32(142); 139ffe3c632Sopenharmony_ci $m->setOptionalUint64(143); 140ffe3c632Sopenharmony_ci $m->setOptionalSint32(-144); 141ffe3c632Sopenharmony_ci $m->setOptionalSint64(-145); 142ffe3c632Sopenharmony_ci $m->setOptionalFixed32(146); 143ffe3c632Sopenharmony_ci $m->setOptionalFixed64(147); 144ffe3c632Sopenharmony_ci $m->setOptionalSfixed32(-146); 145ffe3c632Sopenharmony_ci $m->setOptionalSfixed64(-147); 146ffe3c632Sopenharmony_ci $m->setOptionalFloat(11.5); 147ffe3c632Sopenharmony_ci $m->setOptionalDouble(11.6); 148ffe3c632Sopenharmony_ci $m->setOptionalBool(true); 149ffe3c632Sopenharmony_ci $m->setOptionalString('aa'); 150ffe3c632Sopenharmony_ci $m->setOptionalBytes('bb'); 151ffe3c632Sopenharmony_ci $m->setOptionalEnum(TestEnum::TWO); 152ffe3c632Sopenharmony_ci $m->setOptionalMessage($sub); 153ffe3c632Sopenharmony_ci $m->getOptionalMessage()->SetA(133); 154ffe3c632Sopenharmony_ci 155ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedInt32', -142); 156ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedInt64', -143); 157ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedUint32', 142); 158ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedUint64', 143); 159ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSint32', -144); 160ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSint64', -145); 161ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFixed32', 146); 162ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFixed64', 147); 163ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSfixed32', -146); 164ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSfixed64', -147); 165ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFloat', 11.5); 166ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedDouble', 11.6); 167ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedBool', false); 168ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedString', 'aa'); 169ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedBytes', 'bb'); 170ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedEnum', TestEnum::TWO); 171ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedMessage', new Sub()); 172ffe3c632Sopenharmony_ci $m->getRepeatedMessage()[0]->setA(134); 173ffe3c632Sopenharmony_ci 174ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Int32', -62, -162); 175ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt64Int64', -63, -163); 176ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapUint32Uint32', 62, 162); 177ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapUint64Uint64', 63, 163); 178ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapSint32Sint32', -64, -164); 179ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapSint64Sint64', -65, -165); 180ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapFixed32Fixed32', 66, 166); 181ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapFixed64Fixed64', 67, 167); 182ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapSfixed32Sfixed32', -68, -168); 183ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapSfixed64Sfixed64', -69, -169); 184ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Float', 1, 13.5); 185ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Double', 1, 13.6); 186ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapBoolBool', true, false); 187ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapStringString', 'e', 'ee'); 188ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Bytes', 1, 'ff'); 189ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Enum', 1, TestEnum::TWO); 190ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Message', 1, new Sub()); 191ffe3c632Sopenharmony_ci $m->getMapInt32Message()[1]->SetA(136); 192ffe3c632Sopenharmony_ci 193ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Int32', -162, -162); 194ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt64Int64', -163, -163); 195ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapUint32Uint32', 162, 162); 196ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapUint64Uint64', 163, 163); 197ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapSint32Sint32', -164, -164); 198ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapSint64Sint64', -165, -165); 199ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapFixed32Fixed32', 166, 166); 200ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapFixed64Fixed64', 167, 167); 201ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapSfixed32Sfixed32', -168, -168); 202ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapSfixed64Sfixed64', -169, -169); 203ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Float', 2, 13.5); 204ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Double', 2, 13.6); 205ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapBoolBool', false, false); 206ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapStringString', 'ee', 'ee'); 207ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Bytes', 2, 'ff'); 208ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Enum', 2, TestEnum::TWO); 209ffe3c632Sopenharmony_ci self::kvUpdateHelper($m, 'MapInt32Message', 2, new Sub()); 210ffe3c632Sopenharmony_ci $m->getMapInt32Message()[2]->SetA(136); 211ffe3c632Sopenharmony_ci } 212ffe3c632Sopenharmony_ci 213ffe3c632Sopenharmony_ci public static function assertTestMessage(TestMessage $m) 214ffe3c632Sopenharmony_ci { 215ffe3c632Sopenharmony_ci if (PHP_INT_SIZE == 4) { 216ffe3c632Sopenharmony_ci assert('-43' === $m->getOptionalInt64()); 217ffe3c632Sopenharmony_ci assert('43' === $m->getOptionalUint64()); 218ffe3c632Sopenharmony_ci assert('-45' === $m->getOptionalSint64()); 219ffe3c632Sopenharmony_ci assert('47' === $m->getOptionalFixed64()); 220ffe3c632Sopenharmony_ci assert('-47' === $m->getOptionalSfixed64()); 221ffe3c632Sopenharmony_ci } else { 222ffe3c632Sopenharmony_ci assert(-43 === $m->getOptionalInt64()); 223ffe3c632Sopenharmony_ci assert(43 === $m->getOptionalUint64()); 224ffe3c632Sopenharmony_ci assert(-45 === $m->getOptionalSint64()); 225ffe3c632Sopenharmony_ci assert(47 === $m->getOptionalFixed64()); 226ffe3c632Sopenharmony_ci assert(-47 === $m->getOptionalSfixed64()); 227ffe3c632Sopenharmony_ci } 228ffe3c632Sopenharmony_ci assert(-42 === $m->getOptionalInt32()); 229ffe3c632Sopenharmony_ci assert(42 === $m->getOptionalUint32()); 230ffe3c632Sopenharmony_ci assert(-44 === $m->getOptionalSint32()); 231ffe3c632Sopenharmony_ci assert(46 === $m->getOptionalFixed32()); 232ffe3c632Sopenharmony_ci assert(-46 === $m->getOptionalSfixed32()); 233ffe3c632Sopenharmony_ci assert(1.5 === $m->getOptionalFloat()); 234ffe3c632Sopenharmony_ci assert(1.6 === $m->getOptionalDouble()); 235ffe3c632Sopenharmony_ci assert(true=== $m->getOptionalBool()); 236ffe3c632Sopenharmony_ci assert('a' === $m->getOptionalString()); 237ffe3c632Sopenharmony_ci assert('bbbb' === $m->getOptionalBytes()); 238ffe3c632Sopenharmony_ci assert(TestEnum::ONE === $m->getOptionalEnum()); 239ffe3c632Sopenharmony_ci assert(33 === $m->getOptionalMessage()->getA()); 240ffe3c632Sopenharmony_ci 241ffe3c632Sopenharmony_ci if (PHP_INT_SIZE == 4) { 242ffe3c632Sopenharmony_ci assert('-43' === $m->getRepeatedInt64()[0]); 243ffe3c632Sopenharmony_ci assert('43' === $m->getRepeatedUint64()[0]); 244ffe3c632Sopenharmony_ci assert('-45' === $m->getRepeatedSint64()[0]); 245ffe3c632Sopenharmony_ci assert('47' === $m->getRepeatedFixed64()[0]); 246ffe3c632Sopenharmony_ci assert('-47' === $m->getRepeatedSfixed64()[0]); 247ffe3c632Sopenharmony_ci } else { 248ffe3c632Sopenharmony_ci assert(-43 === $m->getRepeatedInt64()[0]); 249ffe3c632Sopenharmony_ci assert(43 === $m->getRepeatedUint64()[0]); 250ffe3c632Sopenharmony_ci assert(-45 === $m->getRepeatedSint64()[0]); 251ffe3c632Sopenharmony_ci assert(47 === $m->getRepeatedFixed64()[0]); 252ffe3c632Sopenharmony_ci assert(-47 === $m->getRepeatedSfixed64()[0]); 253ffe3c632Sopenharmony_ci } 254ffe3c632Sopenharmony_ci assert(-42 === $m->getRepeatedInt32()[0]); 255ffe3c632Sopenharmony_ci assert(42 === $m->getRepeatedUint32()[0]); 256ffe3c632Sopenharmony_ci assert(-44 === $m->getRepeatedSint32()[0]); 257ffe3c632Sopenharmony_ci assert(46 === $m->getRepeatedFixed32()[0]); 258ffe3c632Sopenharmony_ci assert(-46 === $m->getRepeatedSfixed32()[0]); 259ffe3c632Sopenharmony_ci assert(1.5 === $m->getRepeatedFloat()[0]); 260ffe3c632Sopenharmony_ci assert(1.6 === $m->getRepeatedDouble()[0]); 261ffe3c632Sopenharmony_ci assert(true=== $m->getRepeatedBool()[0]); 262ffe3c632Sopenharmony_ci assert('a' === $m->getRepeatedString()[0]); 263ffe3c632Sopenharmony_ci assert('bbbb' === $m->getRepeatedBytes()[0]); 264ffe3c632Sopenharmony_ci assert(TestEnum::ZERO === $m->getRepeatedEnum()[0]); 265ffe3c632Sopenharmony_ci assert(34 === $m->getRepeatedMessage()[0]->getA()); 266ffe3c632Sopenharmony_ci 267ffe3c632Sopenharmony_ci if (PHP_INT_SIZE == 4) { 268ffe3c632Sopenharmony_ci assert('-53' === $m->getRepeatedInt64()[1]); 269ffe3c632Sopenharmony_ci assert('53' === $m->getRepeatedUint64()[1]); 270ffe3c632Sopenharmony_ci assert('-55' === $m->getRepeatedSint64()[1]); 271ffe3c632Sopenharmony_ci assert('57' === $m->getRepeatedFixed64()[1]); 272ffe3c632Sopenharmony_ci assert('-57' === $m->getRepeatedSfixed64()[1]); 273ffe3c632Sopenharmony_ci } else { 274ffe3c632Sopenharmony_ci assert(-53 === $m->getRepeatedInt64()[1]); 275ffe3c632Sopenharmony_ci assert(53 === $m->getRepeatedUint64()[1]); 276ffe3c632Sopenharmony_ci assert(-55 === $m->getRepeatedSint64()[1]); 277ffe3c632Sopenharmony_ci assert(57 === $m->getRepeatedFixed64()[1]); 278ffe3c632Sopenharmony_ci assert(-57 === $m->getRepeatedSfixed64()[1]); 279ffe3c632Sopenharmony_ci } 280ffe3c632Sopenharmony_ci assert(-52 === $m->getRepeatedInt32()[1]); 281ffe3c632Sopenharmony_ci assert(52 === $m->getRepeatedUint32()[1]); 282ffe3c632Sopenharmony_ci assert(-54 === $m->getRepeatedSint32()[1]); 283ffe3c632Sopenharmony_ci assert(56 === $m->getRepeatedFixed32()[1]); 284ffe3c632Sopenharmony_ci assert(-56 === $m->getRepeatedSfixed32()[1]); 285ffe3c632Sopenharmony_ci assert(2.5 === $m->getRepeatedFloat()[1]); 286ffe3c632Sopenharmony_ci assert(2.6 === $m->getRepeatedDouble()[1]); 287ffe3c632Sopenharmony_ci assert(false === $m->getRepeatedBool()[1]); 288ffe3c632Sopenharmony_ci assert('c' === $m->getRepeatedString()[1]); 289ffe3c632Sopenharmony_ci assert('dddd' === $m->getRepeatedBytes()[1]); 290ffe3c632Sopenharmony_ci assert(TestEnum::ONE === $m->getRepeatedEnum()[1]); 291ffe3c632Sopenharmony_ci assert(35 === $m->getRepeatedMessage()[1]->getA()); 292ffe3c632Sopenharmony_ci 293ffe3c632Sopenharmony_ci if (PHP_INT_SIZE == 4) { 294ffe3c632Sopenharmony_ci assert('-63' === $m->getMapInt64Int64()['-63']); 295ffe3c632Sopenharmony_ci assert('63' === $m->getMapUint64Uint64()['63']); 296ffe3c632Sopenharmony_ci assert('-65' === $m->getMapSint64Sint64()['-65']); 297ffe3c632Sopenharmony_ci assert('67' === $m->getMapFixed64Fixed64()['67']); 298ffe3c632Sopenharmony_ci assert('-69' === $m->getMapSfixed64Sfixed64()['-69']); 299ffe3c632Sopenharmony_ci } else { 300ffe3c632Sopenharmony_ci assert(-63 === $m->getMapInt64Int64()[-63]); 301ffe3c632Sopenharmony_ci assert(63 === $m->getMapUint64Uint64()[63]); 302ffe3c632Sopenharmony_ci assert(-65 === $m->getMapSint64Sint64()[-65]); 303ffe3c632Sopenharmony_ci assert(67 === $m->getMapFixed64Fixed64()[67]); 304ffe3c632Sopenharmony_ci assert(-69 === $m->getMapSfixed64Sfixed64()[-69]); 305ffe3c632Sopenharmony_ci } 306ffe3c632Sopenharmony_ci assert(-62 === $m->getMapInt32Int32()[-62]); 307ffe3c632Sopenharmony_ci assert(62 === $m->getMapUint32Uint32()[62]); 308ffe3c632Sopenharmony_ci assert(-64 === $m->getMapSint32Sint32()[-64]); 309ffe3c632Sopenharmony_ci assert(66 === $m->getMapFixed32Fixed32()[66]); 310ffe3c632Sopenharmony_ci assert(-68 === $m->getMapSfixed32Sfixed32()[-68]); 311ffe3c632Sopenharmony_ci assert(3.5 === $m->getMapInt32Float()[1]); 312ffe3c632Sopenharmony_ci assert(3.6 === $m->getMapInt32Double()[1]); 313ffe3c632Sopenharmony_ci assert(true === $m->getMapBoolBool()[true]); 314ffe3c632Sopenharmony_ci assert('e' === $m->getMapStringString()['e']); 315ffe3c632Sopenharmony_ci assert('ffff' === $m->getMapInt32Bytes()[1]); 316ffe3c632Sopenharmony_ci assert(TestEnum::ONE === $m->getMapInt32Enum()[1]); 317ffe3c632Sopenharmony_ci assert(36 === $m->getMapInt32Message()[1]->GetA()); 318ffe3c632Sopenharmony_ci } 319ffe3c632Sopenharmony_ci 320ffe3c632Sopenharmony_ci public static function getGoldenTestMessage() 321ffe3c632Sopenharmony_ci { 322ffe3c632Sopenharmony_ci return hex2bin( 323ffe3c632Sopenharmony_ci "08D6FFFFFFFFFFFFFFFF01" . 324ffe3c632Sopenharmony_ci "10D5FFFFFFFFFFFFFFFF01" . 325ffe3c632Sopenharmony_ci "182A" . 326ffe3c632Sopenharmony_ci "202B" . 327ffe3c632Sopenharmony_ci "2857" . 328ffe3c632Sopenharmony_ci "3059" . 329ffe3c632Sopenharmony_ci "3D2E000000" . 330ffe3c632Sopenharmony_ci "412F00000000000000" . 331ffe3c632Sopenharmony_ci "4DD2FFFFFF" . 332ffe3c632Sopenharmony_ci "51D1FFFFFFFFFFFFFF" . 333ffe3c632Sopenharmony_ci "5D0000C03F" . 334ffe3c632Sopenharmony_ci "619A9999999999F93F" . 335ffe3c632Sopenharmony_ci "6801" . 336ffe3c632Sopenharmony_ci "720161" . 337ffe3c632Sopenharmony_ci "7A0462626262" . 338ffe3c632Sopenharmony_ci "800101" . 339ffe3c632Sopenharmony_ci "8A01020821" . 340ffe3c632Sopenharmony_ci 341ffe3c632Sopenharmony_ci "FA0114D6FFFFFFFFFFFFFFFF01CCFFFFFFFFFFFFFFFF01" . 342ffe3c632Sopenharmony_ci "820214D5FFFFFFFFFFFFFFFF01CBFFFFFFFFFFFFFFFF01" . 343ffe3c632Sopenharmony_ci "8A02022A34" . 344ffe3c632Sopenharmony_ci "9202022B35" . 345ffe3c632Sopenharmony_ci "9A0202576B" . 346ffe3c632Sopenharmony_ci "A20202596D" . 347ffe3c632Sopenharmony_ci "AA02082E00000038000000" . 348ffe3c632Sopenharmony_ci "B202102F000000000000003900000000000000" . 349ffe3c632Sopenharmony_ci "BA0208D2FFFFFFC8FFFFFF" . 350ffe3c632Sopenharmony_ci "C20210D1FFFFFFFFFFFFFFC7FFFFFFFFFFFFFF" . 351ffe3c632Sopenharmony_ci "CA02080000C03F00002040" . 352ffe3c632Sopenharmony_ci "D202109A9999999999F93FCDCCCCCCCCCC0440" . 353ffe3c632Sopenharmony_ci "DA02020100" . 354ffe3c632Sopenharmony_ci "E2020161" . 355ffe3c632Sopenharmony_ci "E2020163" . 356ffe3c632Sopenharmony_ci "EA020462626262" . 357ffe3c632Sopenharmony_ci "EA020464646464" . 358ffe3c632Sopenharmony_ci "F202020001" . 359ffe3c632Sopenharmony_ci "FA02020822" . 360ffe3c632Sopenharmony_ci "FA02020823" . 361ffe3c632Sopenharmony_ci 362ffe3c632Sopenharmony_ci "BA041608C2FFFFFFFFFFFFFFFF0110C2FFFFFFFFFFFFFFFF01" . 363ffe3c632Sopenharmony_ci "C2041608C1FFFFFFFFFFFFFFFF0110C1FFFFFFFFFFFFFFFF01" . 364ffe3c632Sopenharmony_ci "CA0404083E103E" . 365ffe3c632Sopenharmony_ci "D20404083F103F" . 366ffe3c632Sopenharmony_ci "DA0404087f107F" . 367ffe3c632Sopenharmony_ci "E20406088101108101" . 368ffe3c632Sopenharmony_ci "EA040A0D420000001542000000" . 369ffe3c632Sopenharmony_ci "F20412094300000000000000114300000000000000" . 370ffe3c632Sopenharmony_ci "FA040A0DBCFFFFFF15BCFFFFFF" . 371ffe3c632Sopenharmony_ci "82051209BBFFFFFFFFFFFFFF11BBFFFFFFFFFFFFFF" . 372ffe3c632Sopenharmony_ci "8A050708011500006040" . 373ffe3c632Sopenharmony_ci "92050B080111CDCCCCCCCCCC0C40" . 374ffe3c632Sopenharmony_ci "9A050408011001" . 375ffe3c632Sopenharmony_ci "A205060a0165120165" . 376ffe3c632Sopenharmony_ci "AA05080801120466666666" . 377ffe3c632Sopenharmony_ci "B2050408011001" . 378ffe3c632Sopenharmony_ci "Ba0506080112020824" 379ffe3c632Sopenharmony_ci ); 380ffe3c632Sopenharmony_ci } 381ffe3c632Sopenharmony_ci 382ffe3c632Sopenharmony_ci public static function setTestPackedMessage($m) 383ffe3c632Sopenharmony_ci { 384ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedInt32', -42); 385ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedInt32', -52); 386ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedInt64', -43); 387ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedInt64', -53); 388ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedUint32', 42); 389ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedUint32', 52); 390ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedUint64', 43); 391ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedUint64', 53); 392ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSint32', -44); 393ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSint32', -54); 394ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSint64', -45); 395ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSint64', -55); 396ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFixed32', 46); 397ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFixed32', 56); 398ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFixed64', 47); 399ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFixed64', 57); 400ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSfixed32', -46); 401ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSfixed32', -56); 402ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSfixed64', -47); 403ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedSfixed64', -57); 404ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFloat', 1.5); 405ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedFloat', 2.5); 406ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedDouble', 1.6); 407ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedDouble', 2.6); 408ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedBool', true); 409ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedBool', false); 410ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedEnum', TestEnum::ONE); 411ffe3c632Sopenharmony_ci self::appendHelper($m, 'RepeatedEnum', TestEnum::ZERO); 412ffe3c632Sopenharmony_ci } 413ffe3c632Sopenharmony_ci 414ffe3c632Sopenharmony_ci public static function assertTestPackedMessage($m) 415ffe3c632Sopenharmony_ci { 416ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedInt32())); 417ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedInt64())); 418ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedUint32())); 419ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedUint64())); 420ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedSint32())); 421ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedSint64())); 422ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedFixed32())); 423ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedFixed64())); 424ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedSfixed32())); 425ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedSfixed64())); 426ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedFloat())); 427ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedDouble())); 428ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedBool())); 429ffe3c632Sopenharmony_ci assert(2 === count($m->getRepeatedEnum())); 430ffe3c632Sopenharmony_ci 431ffe3c632Sopenharmony_ci assert(-42 === $m->getRepeatedInt32()[0]); 432ffe3c632Sopenharmony_ci assert(-52 === $m->getRepeatedInt32()[1]); 433ffe3c632Sopenharmony_ci assert(42 === $m->getRepeatedUint32()[0]); 434ffe3c632Sopenharmony_ci assert(52 === $m->getRepeatedUint32()[1]); 435ffe3c632Sopenharmony_ci assert(-44 === $m->getRepeatedSint32()[0]); 436ffe3c632Sopenharmony_ci assert(-54 === $m->getRepeatedSint32()[1]); 437ffe3c632Sopenharmony_ci assert(46 === $m->getRepeatedFixed32()[0]); 438ffe3c632Sopenharmony_ci assert(56 === $m->getRepeatedFixed32()[1]); 439ffe3c632Sopenharmony_ci assert(-46 === $m->getRepeatedSfixed32()[0]); 440ffe3c632Sopenharmony_ci assert(-56 === $m->getRepeatedSfixed32()[1]); 441ffe3c632Sopenharmony_ci assert(1.5 === $m->getRepeatedFloat()[0]); 442ffe3c632Sopenharmony_ci assert(2.5 === $m->getRepeatedFloat()[1]); 443ffe3c632Sopenharmony_ci assert(1.6 === $m->getRepeatedDouble()[0]); 444ffe3c632Sopenharmony_ci assert(2.6 === $m->getRepeatedDouble()[1]); 445ffe3c632Sopenharmony_ci assert(true === $m->getRepeatedBool()[0]); 446ffe3c632Sopenharmony_ci assert(false === $m->getRepeatedBool()[1]); 447ffe3c632Sopenharmony_ci assert(TestEnum::ONE === $m->getRepeatedEnum()[0]); 448ffe3c632Sopenharmony_ci assert(TestEnum::ZERO === $m->getRepeatedEnum()[1]); 449ffe3c632Sopenharmony_ci if (PHP_INT_SIZE == 4) { 450ffe3c632Sopenharmony_ci assert('-43' === $m->getRepeatedInt64()[0]); 451ffe3c632Sopenharmony_ci assert('-53' === $m->getRepeatedInt64()[1]); 452ffe3c632Sopenharmony_ci assert('43' === $m->getRepeatedUint64()[0]); 453ffe3c632Sopenharmony_ci assert('53' === $m->getRepeatedUint64()[1]); 454ffe3c632Sopenharmony_ci assert('-45' === $m->getRepeatedSint64()[0]); 455ffe3c632Sopenharmony_ci assert('-55' === $m->getRepeatedSint64()[1]); 456ffe3c632Sopenharmony_ci assert('47' === $m->getRepeatedFixed64()[0]); 457ffe3c632Sopenharmony_ci assert('57' === $m->getRepeatedFixed64()[1]); 458ffe3c632Sopenharmony_ci assert('-47' === $m->getRepeatedSfixed64()[0]); 459ffe3c632Sopenharmony_ci assert('-57' === $m->getRepeatedSfixed64()[1]); 460ffe3c632Sopenharmony_ci } else { 461ffe3c632Sopenharmony_ci assert(-43 === $m->getRepeatedInt64()[0]); 462ffe3c632Sopenharmony_ci assert(-53 === $m->getRepeatedInt64()[1]); 463ffe3c632Sopenharmony_ci assert(43 === $m->getRepeatedUint64()[0]); 464ffe3c632Sopenharmony_ci assert(53 === $m->getRepeatedUint64()[1]); 465ffe3c632Sopenharmony_ci assert(-45 === $m->getRepeatedSint64()[0]); 466ffe3c632Sopenharmony_ci assert(-55 === $m->getRepeatedSint64()[1]); 467ffe3c632Sopenharmony_ci assert(47 === $m->getRepeatedFixed64()[0]); 468ffe3c632Sopenharmony_ci assert(57 === $m->getRepeatedFixed64()[1]); 469ffe3c632Sopenharmony_ci assert(-47 === $m->getRepeatedSfixed64()[0]); 470ffe3c632Sopenharmony_ci assert(-57 === $m->getRepeatedSfixed64()[1]); 471ffe3c632Sopenharmony_ci } 472ffe3c632Sopenharmony_ci } 473ffe3c632Sopenharmony_ci 474ffe3c632Sopenharmony_ci public static function getGoldenTestPackedMessage() 475ffe3c632Sopenharmony_ci { 476ffe3c632Sopenharmony_ci return hex2bin( 477ffe3c632Sopenharmony_ci "D20514D6FFFFFFFFFFFFFFFF01CCFFFFFFFFFFFFFFFF01" . 478ffe3c632Sopenharmony_ci "DA0514D5FFFFFFFFFFFFFFFF01CBFFFFFFFFFFFFFFFF01" . 479ffe3c632Sopenharmony_ci "E205022A34" . 480ffe3c632Sopenharmony_ci "EA05022B35" . 481ffe3c632Sopenharmony_ci "F20502576B" . 482ffe3c632Sopenharmony_ci "FA0502596D" . 483ffe3c632Sopenharmony_ci "8206082E00000038000000" . 484ffe3c632Sopenharmony_ci "8A06102F000000000000003900000000000000" . 485ffe3c632Sopenharmony_ci "920608D2FFFFFFC8FFFFFF" . 486ffe3c632Sopenharmony_ci "9A0610D1FFFFFFFFFFFFFFC7FFFFFFFFFFFFFF" . 487ffe3c632Sopenharmony_ci "A206080000C03F00002040" . 488ffe3c632Sopenharmony_ci "AA06109A9999999999F93FCDCCCCCCCCCC0440" . 489ffe3c632Sopenharmony_ci "B206020100" . 490ffe3c632Sopenharmony_ci "BA06020100" 491ffe3c632Sopenharmony_ci ); 492ffe3c632Sopenharmony_ci } 493ffe3c632Sopenharmony_ci 494ffe3c632Sopenharmony_ci public static function getGoldenTestUnpackedMessage() 495ffe3c632Sopenharmony_ci { 496ffe3c632Sopenharmony_ci return hex2bin( 497ffe3c632Sopenharmony_ci "D005D6FFFFFFFFFFFFFFFF01D005CCFFFFFFFFFFFFFFFF01" . 498ffe3c632Sopenharmony_ci "D805D5FFFFFFFFFFFFFFFF01D805CBFFFFFFFFFFFFFFFF01" . 499ffe3c632Sopenharmony_ci "E0052AE00534" . 500ffe3c632Sopenharmony_ci "E8052BE80535" . 501ffe3c632Sopenharmony_ci "F00557F0056B" . 502ffe3c632Sopenharmony_ci "F80559F8056D" . 503ffe3c632Sopenharmony_ci "85062E000000850638000000" . 504ffe3c632Sopenharmony_ci "89062F0000000000000089063900000000000000" . 505ffe3c632Sopenharmony_ci "9506D2FFFFFF9506C8FFFFFF" . 506ffe3c632Sopenharmony_ci "9906D1FFFFFFFFFFFFFF9906C7FFFFFFFFFFFFFF" . 507ffe3c632Sopenharmony_ci "A5060000C03FA50600002040" . 508ffe3c632Sopenharmony_ci "A9069A9999999999F93FA906CDCCCCCCCCCC0440" . 509ffe3c632Sopenharmony_ci "B00601B00600" . 510ffe3c632Sopenharmony_ci "B80601B80600" 511ffe3c632Sopenharmony_ci ); 512ffe3c632Sopenharmony_ci } 513ffe3c632Sopenharmony_ci 514ffe3c632Sopenharmony_ci private static function appendHelper($obj, $func_suffix, $value) 515ffe3c632Sopenharmony_ci { 516ffe3c632Sopenharmony_ci $getter_function = 'get'.$func_suffix; 517ffe3c632Sopenharmony_ci $setter_function = 'set'.$func_suffix; 518ffe3c632Sopenharmony_ci 519ffe3c632Sopenharmony_ci $arr = $obj->$getter_function(); 520ffe3c632Sopenharmony_ci $arr[] = $value; 521ffe3c632Sopenharmony_ci $obj->$setter_function($arr); 522ffe3c632Sopenharmony_ci } 523ffe3c632Sopenharmony_ci 524ffe3c632Sopenharmony_ci private static function kvUpdateHelper($obj, $func_suffix, $key, $value) 525ffe3c632Sopenharmony_ci { 526ffe3c632Sopenharmony_ci $getter_function = 'get'.$func_suffix; 527ffe3c632Sopenharmony_ci $setter_function = 'set'.$func_suffix; 528ffe3c632Sopenharmony_ci 529ffe3c632Sopenharmony_ci $arr = $obj->$getter_function(); 530ffe3c632Sopenharmony_ci $arr[$key] = $value; 531ffe3c632Sopenharmony_ci $obj->$setter_function($arr); 532ffe3c632Sopenharmony_ci } 533ffe3c632Sopenharmony_ci} 534