1ffe3c632Sopenharmony_ci// Protocol Buffers - Google's data interchange format 2ffe3c632Sopenharmony_ci// Copyright 2008 Google Inc. All rights reserved. 3ffe3c632Sopenharmony_ci// https://developers.google.com/protocol-buffers/ 4ffe3c632Sopenharmony_ci// 5ffe3c632Sopenharmony_ci// Redistribution and use in source and binary forms, with or without 6ffe3c632Sopenharmony_ci// modification, are permitted provided that the following conditions are 7ffe3c632Sopenharmony_ci// met: 8ffe3c632Sopenharmony_ci// 9ffe3c632Sopenharmony_ci// * Redistributions of source code must retain the above copyright 10ffe3c632Sopenharmony_ci// notice, this list of conditions and the following disclaimer. 11ffe3c632Sopenharmony_ci// * Redistributions in binary form must reproduce the above 12ffe3c632Sopenharmony_ci// copyright notice, this list of conditions and the following disclaimer 13ffe3c632Sopenharmony_ci// in the documentation and/or other materials provided with the 14ffe3c632Sopenharmony_ci// distribution. 15ffe3c632Sopenharmony_ci// * Neither the name of Google Inc. nor the names of its 16ffe3c632Sopenharmony_ci// contributors may be used to endorse or promote products derived from 17ffe3c632Sopenharmony_ci// this software without specific prior written permission. 18ffe3c632Sopenharmony_ci// 19ffe3c632Sopenharmony_ci// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20ffe3c632Sopenharmony_ci// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21ffe3c632Sopenharmony_ci// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22ffe3c632Sopenharmony_ci// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23ffe3c632Sopenharmony_ci// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24ffe3c632Sopenharmony_ci// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25ffe3c632Sopenharmony_ci// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26ffe3c632Sopenharmony_ci// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27ffe3c632Sopenharmony_ci// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28ffe3c632Sopenharmony_ci// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29ffe3c632Sopenharmony_ci// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30ffe3c632Sopenharmony_ci 31ffe3c632Sopenharmony_ci// Test suite is written using Jasmine -- see http://jasmine.github.io/ 32ffe3c632Sopenharmony_ci 33ffe3c632Sopenharmony_cigoog.require('goog.crypt.base64'); 34ffe3c632Sopenharmony_cigoog.require('goog.testing.asserts'); 35ffe3c632Sopenharmony_cigoog.require('jspb.Message'); 36ffe3c632Sopenharmony_ci 37ffe3c632Sopenharmony_ci// CommonJS-LoadFromFile: ../testbinary_pb proto.jspb.test 38ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.ExtendsWithMessage'); 39ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.ForeignEnum'); 40ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.ForeignMessage'); 41ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.TestAllTypes'); 42ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.TestExtendable'); 43ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalBool'); 44ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalBytes'); 45ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalDouble'); 46ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalFixed32'); 47ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalFixed64'); 48ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalFloat'); 49ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalForeignEnum'); 50ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalInt32'); 51ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalInt64'); 52ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalSfixed32'); 53ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalSfixed64'); 54ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalSint32'); 55ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalSint64'); 56ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalString'); 57ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalUint32'); 58ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendOptionalUint64'); 59ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedBoolList'); 60ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedDoubleList'); 61ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedFixed32List'); 62ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedFixed64List'); 63ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedFloatList'); 64ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedForeignEnumList'); 65ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedInt32List'); 66ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedInt64List'); 67ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedSfixed32List'); 68ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedSfixed64List'); 69ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedSint32List'); 70ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedSint64List'); 71ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedUint32List'); 72ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendPackedRepeatedUint64List'); 73ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedBoolList'); 74ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedBytesList'); 75ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedDoubleList'); 76ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedFixed32List'); 77ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedFixed64List'); 78ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedFloatList'); 79ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedForeignEnumList'); 80ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedInt32List'); 81ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedInt64List'); 82ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedSfixed32List'); 83ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedSfixed64List'); 84ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedSint32List'); 85ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedSint64List'); 86ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedStringList'); 87ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedUint32List'); 88ffe3c632Sopenharmony_cigoog.require('proto.jspb.test.extendRepeatedUint64List'); 89ffe3c632Sopenharmony_ci 90ffe3c632Sopenharmony_ci 91ffe3c632Sopenharmony_civar suite = {}; 92ffe3c632Sopenharmony_ci 93ffe3c632Sopenharmony_civar BYTES = new Uint8Array([1, 2, 8, 9]); 94ffe3c632Sopenharmony_ci 95ffe3c632Sopenharmony_civar BYTES_B64 = goog.crypt.base64.encodeByteArray(BYTES); 96ffe3c632Sopenharmony_ci 97ffe3c632Sopenharmony_ci 98ffe3c632Sopenharmony_ci/** 99ffe3c632Sopenharmony_ci * Helper: fill all fields on a TestAllTypes message. 100ffe3c632Sopenharmony_ci * @param {proto.jspb.test.TestAllTypes} msg 101ffe3c632Sopenharmony_ci */ 102ffe3c632Sopenharmony_cifunction fillAllFields(msg) { 103ffe3c632Sopenharmony_ci msg.setOptionalInt32(-42); 104ffe3c632Sopenharmony_ci // can be exactly represented by JS number (64-bit double, i.e., 52-bit 105ffe3c632Sopenharmony_ci // mantissa). 106ffe3c632Sopenharmony_ci msg.setOptionalInt64(-0x7fffffff00000000); 107ffe3c632Sopenharmony_ci msg.setOptionalUint32(0x80000000); 108ffe3c632Sopenharmony_ci msg.setOptionalUint64(0xf000000000000000); 109ffe3c632Sopenharmony_ci msg.setOptionalSint32(-100); 110ffe3c632Sopenharmony_ci msg.setOptionalSint64(-0x8000000000000000); 111ffe3c632Sopenharmony_ci msg.setOptionalFixed32(1234); 112ffe3c632Sopenharmony_ci msg.setOptionalFixed64(0x1234567800000000); 113ffe3c632Sopenharmony_ci msg.setOptionalSfixed32(-1234); 114ffe3c632Sopenharmony_ci msg.setOptionalSfixed64(-0x1234567800000000); 115ffe3c632Sopenharmony_ci msg.setOptionalFloat(1.5); 116ffe3c632Sopenharmony_ci msg.setOptionalDouble(-1.5); 117ffe3c632Sopenharmony_ci msg.setOptionalBool(true); 118ffe3c632Sopenharmony_ci msg.setOptionalString('hello world'); 119ffe3c632Sopenharmony_ci msg.setOptionalBytes(BYTES); 120ffe3c632Sopenharmony_ci msg.setOptionalGroup(new proto.jspb.test.TestAllTypes.OptionalGroup()); 121ffe3c632Sopenharmony_ci msg.getOptionalGroup().setA(100); 122ffe3c632Sopenharmony_ci var submsg = new proto.jspb.test.ForeignMessage(); 123ffe3c632Sopenharmony_ci submsg.setC(16); 124ffe3c632Sopenharmony_ci msg.setOptionalForeignMessage(submsg); 125ffe3c632Sopenharmony_ci msg.setOptionalForeignEnum(proto.jspb.test.ForeignEnum.FOREIGN_FOO); 126ffe3c632Sopenharmony_ci msg.setOneofString('oneof'); 127ffe3c632Sopenharmony_ci 128ffe3c632Sopenharmony_ci 129ffe3c632Sopenharmony_ci msg.setRepeatedInt32List([-42]); 130ffe3c632Sopenharmony_ci msg.setRepeatedInt64List([-0x7fffffff00000000]); 131ffe3c632Sopenharmony_ci msg.setRepeatedUint32List([0x80000000]); 132ffe3c632Sopenharmony_ci msg.setRepeatedUint64List([0xf000000000000000]); 133ffe3c632Sopenharmony_ci msg.setRepeatedSint32List([-100]); 134ffe3c632Sopenharmony_ci msg.setRepeatedSint64List([-0x8000000000000000]); 135ffe3c632Sopenharmony_ci msg.setRepeatedFixed32List([1234]); 136ffe3c632Sopenharmony_ci msg.setRepeatedFixed64List([0x1234567800000000]); 137ffe3c632Sopenharmony_ci msg.setRepeatedSfixed32List([-1234]); 138ffe3c632Sopenharmony_ci msg.setRepeatedSfixed64List([-0x1234567800000000]); 139ffe3c632Sopenharmony_ci msg.setRepeatedFloatList([1.5]); 140ffe3c632Sopenharmony_ci msg.setRepeatedDoubleList([-1.5]); 141ffe3c632Sopenharmony_ci msg.setRepeatedBoolList([true]); 142ffe3c632Sopenharmony_ci msg.setRepeatedStringList(['hello world']); 143ffe3c632Sopenharmony_ci msg.setRepeatedBytesList([BYTES, BYTES]); 144ffe3c632Sopenharmony_ci msg.setRepeatedGroupList([new proto.jspb.test.TestAllTypes.RepeatedGroup()]); 145ffe3c632Sopenharmony_ci msg.getRepeatedGroupList()[0].setA(100); 146ffe3c632Sopenharmony_ci submsg = new proto.jspb.test.ForeignMessage(); 147ffe3c632Sopenharmony_ci submsg.setC(1000); 148ffe3c632Sopenharmony_ci msg.setRepeatedForeignMessageList([submsg]); 149ffe3c632Sopenharmony_ci msg.setRepeatedForeignEnumList([proto.jspb.test.ForeignEnum.FOREIGN_FOO]); 150ffe3c632Sopenharmony_ci 151ffe3c632Sopenharmony_ci msg.setPackedRepeatedInt32List([-42]); 152ffe3c632Sopenharmony_ci msg.setPackedRepeatedInt64List([-0x7fffffff00000000]); 153ffe3c632Sopenharmony_ci msg.setPackedRepeatedUint32List([0x80000000]); 154ffe3c632Sopenharmony_ci msg.setPackedRepeatedUint64List([0xf000000000000000]); 155ffe3c632Sopenharmony_ci msg.setPackedRepeatedSint32List([-100]); 156ffe3c632Sopenharmony_ci msg.setPackedRepeatedSint64List([-0x8000000000000000]); 157ffe3c632Sopenharmony_ci msg.setPackedRepeatedFixed32List([1234]); 158ffe3c632Sopenharmony_ci msg.setPackedRepeatedFixed64List([0x1234567800000000]); 159ffe3c632Sopenharmony_ci msg.setPackedRepeatedSfixed32List([-1234]); 160ffe3c632Sopenharmony_ci msg.setPackedRepeatedSfixed64List([-0x1234567800000000]); 161ffe3c632Sopenharmony_ci msg.setPackedRepeatedFloatList([1.5]); 162ffe3c632Sopenharmony_ci msg.setPackedRepeatedDoubleList([-1.5]); 163ffe3c632Sopenharmony_ci msg.setPackedRepeatedBoolList([true]); 164ffe3c632Sopenharmony_ci 165ffe3c632Sopenharmony_ci} 166ffe3c632Sopenharmony_ci 167ffe3c632Sopenharmony_ci 168ffe3c632Sopenharmony_ci/** 169ffe3c632Sopenharmony_ci * Helper: compare a bytes field to an expected value 170ffe3c632Sopenharmony_ci * @param {Uint8Array|string} arr 171ffe3c632Sopenharmony_ci * @param {Uint8Array} expected 172ffe3c632Sopenharmony_ci * @return {boolean} 173ffe3c632Sopenharmony_ci */ 174ffe3c632Sopenharmony_cifunction bytesCompare(arr, expected) { 175ffe3c632Sopenharmony_ci if (typeof arr === 'string') { 176ffe3c632Sopenharmony_ci arr = goog.crypt.base64.decodeStringToUint8Array(arr); 177ffe3c632Sopenharmony_ci } 178ffe3c632Sopenharmony_ci if (arr.length != expected.length) { 179ffe3c632Sopenharmony_ci return false; 180ffe3c632Sopenharmony_ci } 181ffe3c632Sopenharmony_ci for (var i = 0; i < arr.length; i++) { 182ffe3c632Sopenharmony_ci if (arr[i] != expected[i]) { 183ffe3c632Sopenharmony_ci return false; 184ffe3c632Sopenharmony_ci } 185ffe3c632Sopenharmony_ci } 186ffe3c632Sopenharmony_ci return true; 187ffe3c632Sopenharmony_ci} 188ffe3c632Sopenharmony_ci 189ffe3c632Sopenharmony_ci 190ffe3c632Sopenharmony_ci/** 191ffe3c632Sopenharmony_ci * Helper: verify contents of given TestAllTypes message as set by 192ffe3c632Sopenharmony_ci * fillAllFields(). 193ffe3c632Sopenharmony_ci * @param {proto.jspb.test.TestAllTypes} original 194ffe3c632Sopenharmony_ci * @param {proto.jspb.test.TestAllTypes} copy 195ffe3c632Sopenharmony_ci */ 196ffe3c632Sopenharmony_cifunction checkAllFields(original, copy) { 197ffe3c632Sopenharmony_ci assertTrue(jspb.Message.equals(original, copy)); 198ffe3c632Sopenharmony_ci 199ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalInt32(), -42); 200ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalInt64(), -0x7fffffff00000000); 201ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalUint32(), 0x80000000); 202ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalUint64(), 0xf000000000000000); 203ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalSint32(), -100); 204ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalSint64(), -0x8000000000000000); 205ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalFixed32(), 1234); 206ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalFixed64(), 0x1234567800000000); 207ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalSfixed32(), -1234); 208ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalSfixed64(), -0x1234567800000000); 209ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalFloat(), 1.5); 210ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalDouble(), -1.5); 211ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalBool(), true); 212ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalString(), 'hello world'); 213ffe3c632Sopenharmony_ci assertEquals(true, bytesCompare(copy.getOptionalBytes(), BYTES)); 214ffe3c632Sopenharmony_ci assertEquals(true, bytesCompare(copy.getOptionalBytes_asU8(), BYTES)); 215ffe3c632Sopenharmony_ci assertEquals( 216ffe3c632Sopenharmony_ci copy.getOptionalBytes_asB64(), goog.crypt.base64.encodeByteArray(BYTES)); 217ffe3c632Sopenharmony_ci 218ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalGroup().getA(), 100); 219ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalForeignMessage().getC(), 16); 220ffe3c632Sopenharmony_ci assertEquals(copy.getOptionalForeignEnum(), 221ffe3c632Sopenharmony_ci proto.jspb.test.ForeignEnum.FOREIGN_FOO); 222ffe3c632Sopenharmony_ci 223ffe3c632Sopenharmony_ci 224ffe3c632Sopenharmony_ci assertEquals(copy.getOneofString(), 'oneof'); 225ffe3c632Sopenharmony_ci assertEquals(copy.getOneofFieldCase(), 226ffe3c632Sopenharmony_ci proto.jspb.test.TestAllTypes.OneofFieldCase.ONEOF_STRING); 227ffe3c632Sopenharmony_ci 228ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedInt32List(), [-42]); 229ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedInt64List(), [-0x7fffffff00000000]); 230ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedUint32List(), [0x80000000]); 231ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedUint64List(), [0xf000000000000000]); 232ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedSint32List(), [-100]); 233ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedSint64List(), [-0x8000000000000000]); 234ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedFixed32List(), [1234]); 235ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedFixed64List(), [0x1234567800000000]); 236ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedSfixed32List(), [-1234]); 237ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedSfixed64List(), [-0x1234567800000000]); 238ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedFloatList(), [1.5]); 239ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedDoubleList(), [-1.5]); 240ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedBoolList(), [true]); 241ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedStringList(), ['hello world']); 242ffe3c632Sopenharmony_ci assertEquals(copy.getRepeatedBytesList().length, 2); 243ffe3c632Sopenharmony_ci assertEquals(true, bytesCompare(copy.getRepeatedBytesList_asU8()[0], BYTES)); 244ffe3c632Sopenharmony_ci assertEquals(true, bytesCompare(copy.getRepeatedBytesList()[0], BYTES)); 245ffe3c632Sopenharmony_ci assertEquals(true, bytesCompare(copy.getRepeatedBytesList_asU8()[1], BYTES)); 246ffe3c632Sopenharmony_ci assertEquals(copy.getRepeatedBytesList_asB64()[0], BYTES_B64); 247ffe3c632Sopenharmony_ci assertEquals(copy.getRepeatedBytesList_asB64()[1], BYTES_B64); 248ffe3c632Sopenharmony_ci assertEquals(copy.getRepeatedGroupList().length, 1); 249ffe3c632Sopenharmony_ci assertEquals(copy.getRepeatedGroupList()[0].getA(), 100); 250ffe3c632Sopenharmony_ci assertEquals(copy.getRepeatedForeignMessageList().length, 1); 251ffe3c632Sopenharmony_ci assertEquals(copy.getRepeatedForeignMessageList()[0].getC(), 1000); 252ffe3c632Sopenharmony_ci assertElementsEquals(copy.getRepeatedForeignEnumList(), 253ffe3c632Sopenharmony_ci [proto.jspb.test.ForeignEnum.FOREIGN_FOO]); 254ffe3c632Sopenharmony_ci 255ffe3c632Sopenharmony_ci assertElementsEquals(copy.getPackedRepeatedInt32List(), [-42]); 256ffe3c632Sopenharmony_ci assertElementsEquals(copy.getPackedRepeatedInt64List(), 257ffe3c632Sopenharmony_ci [-0x7fffffff00000000]); 258ffe3c632Sopenharmony_ci assertElementsEquals(copy.getPackedRepeatedUint32List(), [0x80000000]); 259ffe3c632Sopenharmony_ci assertElementsEquals(copy.getPackedRepeatedUint64List(), 260ffe3c632Sopenharmony_ci [0xf000000000000000]); 261ffe3c632Sopenharmony_ci assertElementsEquals(copy.getPackedRepeatedSint32List(), [-100]); 262ffe3c632Sopenharmony_ci assertElementsEquals(copy.getPackedRepeatedSint64List(), 263ffe3c632Sopenharmony_ci [-0x8000000000000000]); 264ffe3c632Sopenharmony_ci assertElementsEquals(copy.getPackedRepeatedFixed32List(), [1234]); 265ffe3c632Sopenharmony_ci assertElementsEquals(copy.getPackedRepeatedFixed64List(), 266ffe3c632Sopenharmony_ci [0x1234567800000000]); 267ffe3c632Sopenharmony_ci assertElementsEquals(copy.getPackedRepeatedSfixed32List(), [-1234]); 268ffe3c632Sopenharmony_ci assertElementsEquals(copy.getPackedRepeatedSfixed64List(), 269ffe3c632Sopenharmony_ci [-0x1234567800000000]); 270ffe3c632Sopenharmony_ci assertElementsEquals(copy.getPackedRepeatedFloatList(), [1.5]); 271ffe3c632Sopenharmony_ci assertElementsEquals(copy.getPackedRepeatedDoubleList(), [-1.5]); 272ffe3c632Sopenharmony_ci 273ffe3c632Sopenharmony_ci} 274ffe3c632Sopenharmony_ci 275ffe3c632Sopenharmony_ci 276ffe3c632Sopenharmony_ci/** 277ffe3c632Sopenharmony_ci * Helper: verify that all expected extensions are present. 278ffe3c632Sopenharmony_ci * @param {!proto.jspb.test.TestExtendable} msg 279ffe3c632Sopenharmony_ci */ 280ffe3c632Sopenharmony_cifunction checkExtensions(msg) { 281ffe3c632Sopenharmony_ci assertEquals(-42, 282ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalInt32)); 283ffe3c632Sopenharmony_ci assertEquals(-0x7fffffff00000000, 284ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalInt64)); 285ffe3c632Sopenharmony_ci assertEquals(0x80000000, 286ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalUint32)); 287ffe3c632Sopenharmony_ci assertEquals(0xf000000000000000, 288ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalUint64)); 289ffe3c632Sopenharmony_ci assertEquals(-100, 290ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalSint32)); 291ffe3c632Sopenharmony_ci assertEquals(-0x8000000000000000, 292ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalSint64)); 293ffe3c632Sopenharmony_ci assertEquals(1234, 294ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalFixed32)); 295ffe3c632Sopenharmony_ci assertEquals(0x1234567800000000, 296ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalFixed64)); 297ffe3c632Sopenharmony_ci assertEquals(-1234, 298ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalSfixed32)); 299ffe3c632Sopenharmony_ci assertEquals(-0x1234567800000000, 300ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalSfixed64)); 301ffe3c632Sopenharmony_ci assertEquals(1.5, 302ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalFloat)); 303ffe3c632Sopenharmony_ci assertEquals(-1.5, 304ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalDouble)); 305ffe3c632Sopenharmony_ci assertEquals(true, 306ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalBool)); 307ffe3c632Sopenharmony_ci assertEquals('hello world', 308ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalString)); 309ffe3c632Sopenharmony_ci assertEquals( 310ffe3c632Sopenharmony_ci true, bytesCompare( 311ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendOptionalBytes), BYTES)); 312ffe3c632Sopenharmony_ci assertEquals(16, 313ffe3c632Sopenharmony_ci msg.getExtension( 314ffe3c632Sopenharmony_ci proto.jspb.test.ExtendsWithMessage.optionalExtension).getFoo()); 315ffe3c632Sopenharmony_ci 316ffe3c632Sopenharmony_ci 317ffe3c632Sopenharmony_ci assertElementsEquals( 318ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedInt32List), 319ffe3c632Sopenharmony_ci [-42]); 320ffe3c632Sopenharmony_ci assertElementsEquals( 321ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedInt64List), 322ffe3c632Sopenharmony_ci [-0x7fffffff00000000]); 323ffe3c632Sopenharmony_ci assertElementsEquals( 324ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedUint32List), 325ffe3c632Sopenharmony_ci [0x80000000]); 326ffe3c632Sopenharmony_ci assertElementsEquals( 327ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedUint64List), 328ffe3c632Sopenharmony_ci [0xf000000000000000]); 329ffe3c632Sopenharmony_ci assertElementsEquals( 330ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedSint32List), 331ffe3c632Sopenharmony_ci [-100]); 332ffe3c632Sopenharmony_ci assertElementsEquals( 333ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedSint64List), 334ffe3c632Sopenharmony_ci [-0x8000000000000000]); 335ffe3c632Sopenharmony_ci assertElementsEquals( 336ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedFixed32List), 337ffe3c632Sopenharmony_ci [1234]); 338ffe3c632Sopenharmony_ci assertElementsEquals( 339ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedFixed64List), 340ffe3c632Sopenharmony_ci [0x1234567800000000]); 341ffe3c632Sopenharmony_ci assertElementsEquals( 342ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedSfixed32List), 343ffe3c632Sopenharmony_ci [-1234]); 344ffe3c632Sopenharmony_ci assertElementsEquals( 345ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedSfixed64List), 346ffe3c632Sopenharmony_ci [-0x1234567800000000]); 347ffe3c632Sopenharmony_ci assertElementsEquals( 348ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedFloatList), 349ffe3c632Sopenharmony_ci [1.5]); 350ffe3c632Sopenharmony_ci assertElementsEquals( 351ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedDoubleList), 352ffe3c632Sopenharmony_ci [-1.5]); 353ffe3c632Sopenharmony_ci assertElementsEquals( 354ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedBoolList), 355ffe3c632Sopenharmony_ci [true]); 356ffe3c632Sopenharmony_ci assertElementsEquals( 357ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedStringList), 358ffe3c632Sopenharmony_ci ['hello world']); 359ffe3c632Sopenharmony_ci assertEquals( 360ffe3c632Sopenharmony_ci true, 361ffe3c632Sopenharmony_ci bytesCompare( 362ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedBytesList)[0], BYTES)); 363ffe3c632Sopenharmony_ci assertEquals(1000, 364ffe3c632Sopenharmony_ci msg.getExtension( 365ffe3c632Sopenharmony_ci proto.jspb.test.ExtendsWithMessage.repeatedExtensionList)[0] 366ffe3c632Sopenharmony_ci .getFoo()); 367ffe3c632Sopenharmony_ci assertElementsEquals( 368ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendRepeatedForeignEnumList), 369ffe3c632Sopenharmony_ci [proto.jspb.test.ForeignEnum.FOREIGN_FOO]); 370ffe3c632Sopenharmony_ci 371ffe3c632Sopenharmony_ci 372ffe3c632Sopenharmony_ci assertElementsEquals( 373ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedInt32List), 374ffe3c632Sopenharmony_ci [-42]); 375ffe3c632Sopenharmony_ci assertElementsEquals( 376ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedInt64List), 377ffe3c632Sopenharmony_ci [-0x7fffffff00000000]); 378ffe3c632Sopenharmony_ci assertElementsEquals( 379ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedUint32List), 380ffe3c632Sopenharmony_ci [0x80000000]); 381ffe3c632Sopenharmony_ci assertElementsEquals( 382ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedUint64List), 383ffe3c632Sopenharmony_ci [0xf000000000000000]); 384ffe3c632Sopenharmony_ci assertElementsEquals( 385ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedSint32List), 386ffe3c632Sopenharmony_ci [-100]); 387ffe3c632Sopenharmony_ci assertElementsEquals( 388ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedSint64List), 389ffe3c632Sopenharmony_ci [-0x8000000000000000]); 390ffe3c632Sopenharmony_ci assertElementsEquals( 391ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedFixed32List), 392ffe3c632Sopenharmony_ci [1234]); 393ffe3c632Sopenharmony_ci assertElementsEquals( 394ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedFixed64List), 395ffe3c632Sopenharmony_ci [0x1234567800000000]); 396ffe3c632Sopenharmony_ci assertElementsEquals( 397ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedSfixed32List), 398ffe3c632Sopenharmony_ci [-1234]); 399ffe3c632Sopenharmony_ci assertElementsEquals( 400ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedSfixed64List), 401ffe3c632Sopenharmony_ci [-0x1234567800000000]); 402ffe3c632Sopenharmony_ci assertElementsEquals( 403ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedFloatList), 404ffe3c632Sopenharmony_ci [1.5]); 405ffe3c632Sopenharmony_ci assertElementsEquals( 406ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedDoubleList), 407ffe3c632Sopenharmony_ci [-1.5]); 408ffe3c632Sopenharmony_ci assertElementsEquals( 409ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedBoolList), 410ffe3c632Sopenharmony_ci [true]); 411ffe3c632Sopenharmony_ci assertElementsEquals( 412ffe3c632Sopenharmony_ci msg.getExtension(proto.jspb.test.extendPackedRepeatedForeignEnumList), 413ffe3c632Sopenharmony_ci [proto.jspb.test.ForeignEnum.FOREIGN_FOO]); 414ffe3c632Sopenharmony_ci 415ffe3c632Sopenharmony_ci} 416ffe3c632Sopenharmony_ci 417ffe3c632Sopenharmony_ci 418ffe3c632Sopenharmony_cidescribe('protoBinaryTest', function() { 419ffe3c632Sopenharmony_ci /** 420ffe3c632Sopenharmony_ci * Tests a basic serialization-deserializaton round-trip with all supported 421ffe3c632Sopenharmony_ci * field types (on the TestAllTypes message type). 422ffe3c632Sopenharmony_ci */ 423ffe3c632Sopenharmony_ci it('testRoundTrip', function() { 424ffe3c632Sopenharmony_ci var msg = new proto.jspb.test.TestAllTypes(); 425ffe3c632Sopenharmony_ci fillAllFields(msg); 426ffe3c632Sopenharmony_ci var encoded = msg.serializeBinary(); 427ffe3c632Sopenharmony_ci var decoded = proto.jspb.test.TestAllTypes.deserializeBinary(encoded); 428ffe3c632Sopenharmony_ci checkAllFields(msg, decoded); 429ffe3c632Sopenharmony_ci }); 430ffe3c632Sopenharmony_ci 431ffe3c632Sopenharmony_ci /** 432ffe3c632Sopenharmony_ci * Test that base64 string and Uint8Array are interchangeable in bytes fields. 433ffe3c632Sopenharmony_ci */ 434ffe3c632Sopenharmony_ci it('testBytesFieldsGettersInterop', function() { 435ffe3c632Sopenharmony_ci var msg = new proto.jspb.test.TestAllTypes(); 436ffe3c632Sopenharmony_ci // Set from a base64 string and check all the getters work. 437ffe3c632Sopenharmony_ci msg.setOptionalBytes(BYTES_B64); 438ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes_asU8(), BYTES)); 439ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes_asB64(), BYTES)); 440ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes(), BYTES)); 441ffe3c632Sopenharmony_ci 442ffe3c632Sopenharmony_ci // Test binary serialize round trip doesn't break it. 443ffe3c632Sopenharmony_ci msg = proto.jspb.test.TestAllTypes.deserializeBinary(msg.serializeBinary()); 444ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes_asU8(), BYTES)); 445ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes_asB64(), BYTES)); 446ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes(), BYTES)); 447ffe3c632Sopenharmony_ci 448ffe3c632Sopenharmony_ci msg = new proto.jspb.test.TestAllTypes(); 449ffe3c632Sopenharmony_ci // Set from a Uint8Array and check all the getters work. 450ffe3c632Sopenharmony_ci msg.setOptionalBytes(BYTES); 451ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes_asU8(), BYTES)); 452ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes_asB64(), BYTES)); 453ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes(), BYTES)); 454ffe3c632Sopenharmony_ci 455ffe3c632Sopenharmony_ci }); 456ffe3c632Sopenharmony_ci 457ffe3c632Sopenharmony_ci /** 458ffe3c632Sopenharmony_ci * Test that bytes setters will receive result of any of the getters. 459ffe3c632Sopenharmony_ci */ 460ffe3c632Sopenharmony_ci it('testBytesFieldsSettersInterop', function() { 461ffe3c632Sopenharmony_ci var msg = new proto.jspb.test.TestAllTypes(); 462ffe3c632Sopenharmony_ci msg.setOptionalBytes(BYTES); 463ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes(), BYTES)); 464ffe3c632Sopenharmony_ci 465ffe3c632Sopenharmony_ci msg.setOptionalBytes(msg.getOptionalBytes()); 466ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes(), BYTES)); 467ffe3c632Sopenharmony_ci msg.setOptionalBytes(msg.getOptionalBytes_asB64()); 468ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes(), BYTES)); 469ffe3c632Sopenharmony_ci msg.setOptionalBytes(msg.getOptionalBytes_asU8()); 470ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getOptionalBytes(), BYTES)); 471ffe3c632Sopenharmony_ci }); 472ffe3c632Sopenharmony_ci 473ffe3c632Sopenharmony_ci /** 474ffe3c632Sopenharmony_ci * Test that bytes setters will receive result of any of the getters. 475ffe3c632Sopenharmony_ci */ 476ffe3c632Sopenharmony_ci it('testRepeatedBytesGetters', function() { 477ffe3c632Sopenharmony_ci var msg = new proto.jspb.test.TestAllTypes(); 478ffe3c632Sopenharmony_ci 479ffe3c632Sopenharmony_ci function assertGetters() { 480ffe3c632Sopenharmony_ci assertTrue(typeof msg.getRepeatedBytesList_asB64()[0] === 'string'); 481ffe3c632Sopenharmony_ci assertTrue(typeof msg.getRepeatedBytesList_asB64()[1] === 'string'); 482ffe3c632Sopenharmony_ci assertTrue(msg.getRepeatedBytesList_asU8()[0] instanceof Uint8Array); 483ffe3c632Sopenharmony_ci assertTrue(msg.getRepeatedBytesList_asU8()[1] instanceof Uint8Array); 484ffe3c632Sopenharmony_ci 485ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getRepeatedBytesList()[0], BYTES)); 486ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getRepeatedBytesList()[1], BYTES)); 487ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getRepeatedBytesList_asB64()[0], BYTES)); 488ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getRepeatedBytesList_asB64()[1], BYTES)); 489ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getRepeatedBytesList_asU8()[0], BYTES)); 490ffe3c632Sopenharmony_ci assertTrue(bytesCompare(msg.getRepeatedBytesList_asU8()[1], BYTES)); 491ffe3c632Sopenharmony_ci } 492ffe3c632Sopenharmony_ci 493ffe3c632Sopenharmony_ci msg.setRepeatedBytesList([BYTES, BYTES]); 494ffe3c632Sopenharmony_ci assertGetters(); 495ffe3c632Sopenharmony_ci 496ffe3c632Sopenharmony_ci msg.setRepeatedBytesList([BYTES_B64, BYTES_B64]); 497ffe3c632Sopenharmony_ci assertGetters(); 498ffe3c632Sopenharmony_ci 499ffe3c632Sopenharmony_ci msg.setRepeatedBytesList(null); 500ffe3c632Sopenharmony_ci assertEquals(0, msg.getRepeatedBytesList().length); 501ffe3c632Sopenharmony_ci assertEquals(0, msg.getRepeatedBytesList_asB64().length); 502ffe3c632Sopenharmony_ci assertEquals(0, msg.getRepeatedBytesList_asU8().length); 503ffe3c632Sopenharmony_ci }); 504ffe3c632Sopenharmony_ci 505ffe3c632Sopenharmony_ci /** 506ffe3c632Sopenharmony_ci * Helper: fill all extension values. 507ffe3c632Sopenharmony_ci * @param {proto.jspb.test.TestExtendable} msg 508ffe3c632Sopenharmony_ci */ 509ffe3c632Sopenharmony_ci function fillExtensions(msg) { 510ffe3c632Sopenharmony_ci msg.setExtension( 511ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalInt32, -42); 512ffe3c632Sopenharmony_ci msg.setExtension( 513ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalInt64, -0x7fffffff00000000); 514ffe3c632Sopenharmony_ci msg.setExtension( 515ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalUint32, 0x80000000); 516ffe3c632Sopenharmony_ci msg.setExtension( 517ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalUint64, 0xf000000000000000); 518ffe3c632Sopenharmony_ci msg.setExtension( 519ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalSint32, -100); 520ffe3c632Sopenharmony_ci msg.setExtension( 521ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalSint64, -0x8000000000000000); 522ffe3c632Sopenharmony_ci msg.setExtension( 523ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalFixed32, 1234); 524ffe3c632Sopenharmony_ci msg.setExtension( 525ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalFixed64, 0x1234567800000000); 526ffe3c632Sopenharmony_ci msg.setExtension( 527ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalSfixed32, -1234); 528ffe3c632Sopenharmony_ci msg.setExtension( 529ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalSfixed64, -0x1234567800000000); 530ffe3c632Sopenharmony_ci msg.setExtension( 531ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalFloat, 1.5); 532ffe3c632Sopenharmony_ci msg.setExtension( 533ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalDouble, -1.5); 534ffe3c632Sopenharmony_ci msg.setExtension( 535ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalBool, true); 536ffe3c632Sopenharmony_ci msg.setExtension( 537ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalString, 'hello world'); 538ffe3c632Sopenharmony_ci msg.setExtension(proto.jspb.test.extendOptionalBytes, BYTES); 539ffe3c632Sopenharmony_ci var submsg = new proto.jspb.test.ExtendsWithMessage(); 540ffe3c632Sopenharmony_ci submsg.setFoo(16); 541ffe3c632Sopenharmony_ci msg.setExtension( 542ffe3c632Sopenharmony_ci proto.jspb.test.ExtendsWithMessage.optionalExtension, submsg); 543ffe3c632Sopenharmony_ci msg.setExtension( 544ffe3c632Sopenharmony_ci proto.jspb.test.extendOptionalForeignEnum, 545ffe3c632Sopenharmony_ci proto.jspb.test.ForeignEnum.FOREIGN_FOO); 546ffe3c632Sopenharmony_ci 547ffe3c632Sopenharmony_ci 548ffe3c632Sopenharmony_ci msg.setExtension( 549ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedInt32List, [-42]); 550ffe3c632Sopenharmony_ci msg.setExtension( 551ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedInt64List, [-0x7fffffff00000000]); 552ffe3c632Sopenharmony_ci msg.setExtension( 553ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedUint32List, [0x80000000]); 554ffe3c632Sopenharmony_ci msg.setExtension( 555ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedUint64List, [0xf000000000000000]); 556ffe3c632Sopenharmony_ci msg.setExtension( 557ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedSint32List, [-100]); 558ffe3c632Sopenharmony_ci msg.setExtension( 559ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedSint64List, [-0x8000000000000000]); 560ffe3c632Sopenharmony_ci msg.setExtension( 561ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedFixed32List, [1234]); 562ffe3c632Sopenharmony_ci msg.setExtension( 563ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedFixed64List, [0x1234567800000000]); 564ffe3c632Sopenharmony_ci msg.setExtension( 565ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedSfixed32List, [-1234]); 566ffe3c632Sopenharmony_ci msg.setExtension( 567ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedSfixed64List, [-0x1234567800000000]); 568ffe3c632Sopenharmony_ci msg.setExtension( 569ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedFloatList, [1.5]); 570ffe3c632Sopenharmony_ci msg.setExtension( 571ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedDoubleList, [-1.5]); 572ffe3c632Sopenharmony_ci msg.setExtension( 573ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedBoolList, [true]); 574ffe3c632Sopenharmony_ci msg.setExtension( 575ffe3c632Sopenharmony_ci proto.jspb.test.extendRepeatedStringList, ['hello world']); 576ffe3c632Sopenharmony_ci msg.setExtension(proto.jspb.test.extendRepeatedBytesList, [BYTES]); 577ffe3c632Sopenharmony_ci submsg = new proto.jspb.test.ExtendsWithMessage(); 578ffe3c632Sopenharmony_ci submsg.setFoo(1000); 579ffe3c632Sopenharmony_ci msg.setExtension( 580ffe3c632Sopenharmony_ci proto.jspb.test.ExtendsWithMessage.repeatedExtensionList, [submsg]); 581ffe3c632Sopenharmony_ci msg.setExtension(proto.jspb.test.extendRepeatedForeignEnumList, 582ffe3c632Sopenharmony_ci [proto.jspb.test.ForeignEnum.FOREIGN_FOO]); 583ffe3c632Sopenharmony_ci 584ffe3c632Sopenharmony_ci 585ffe3c632Sopenharmony_ci msg.setExtension( 586ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedInt32List, [-42]); 587ffe3c632Sopenharmony_ci msg.setExtension( 588ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedInt64List, [-0x7fffffff00000000]); 589ffe3c632Sopenharmony_ci msg.setExtension( 590ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedUint32List, [0x80000000]); 591ffe3c632Sopenharmony_ci msg.setExtension( 592ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedUint64List, [0xf000000000000000]); 593ffe3c632Sopenharmony_ci msg.setExtension( 594ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedSint32List, [-100]); 595ffe3c632Sopenharmony_ci msg.setExtension( 596ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedSint64List, [-0x8000000000000000]); 597ffe3c632Sopenharmony_ci msg.setExtension( 598ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedFixed32List, [1234]); 599ffe3c632Sopenharmony_ci msg.setExtension( 600ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedFixed64List, [0x1234567800000000]); 601ffe3c632Sopenharmony_ci msg.setExtension( 602ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedSfixed32List, [-1234]); 603ffe3c632Sopenharmony_ci msg.setExtension( 604ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedSfixed64List, 605ffe3c632Sopenharmony_ci [-0x1234567800000000]); 606ffe3c632Sopenharmony_ci msg.setExtension( 607ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedFloatList, [1.5]); 608ffe3c632Sopenharmony_ci msg.setExtension( 609ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedDoubleList, [-1.5]); 610ffe3c632Sopenharmony_ci msg.setExtension( 611ffe3c632Sopenharmony_ci proto.jspb.test.extendPackedRepeatedBoolList, [true]); 612ffe3c632Sopenharmony_ci msg.setExtension(proto.jspb.test.extendPackedRepeatedForeignEnumList, 613ffe3c632Sopenharmony_ci [proto.jspb.test.ForeignEnum.FOREIGN_FOO]); 614ffe3c632Sopenharmony_ci 615ffe3c632Sopenharmony_ci } 616ffe3c632Sopenharmony_ci 617ffe3c632Sopenharmony_ci 618ffe3c632Sopenharmony_ci /** 619ffe3c632Sopenharmony_ci * Tests extension serialization and deserialization. 620ffe3c632Sopenharmony_ci */ 621ffe3c632Sopenharmony_ci it('testExtensions', function() { 622ffe3c632Sopenharmony_ci var msg = new proto.jspb.test.TestExtendable(); 623ffe3c632Sopenharmony_ci fillExtensions(msg); 624ffe3c632Sopenharmony_ci var encoded = msg.serializeBinary(); 625ffe3c632Sopenharmony_ci var decoded = proto.jspb.test.TestExtendable.deserializeBinary(encoded); 626ffe3c632Sopenharmony_ci checkExtensions(decoded); 627ffe3c632Sopenharmony_ci }); 628ffe3c632Sopenharmony_ci}); 629