1ffe3c632Sopenharmony_ci/** 2ffe3c632Sopenharmony_ci * @fileoverview Test data for int32 encoding and decoding. 3ffe3c632Sopenharmony_ci */ 4ffe3c632Sopenharmony_cigoog.module('protobuf.binary.int32TestPairs'); 5ffe3c632Sopenharmony_ci 6ffe3c632Sopenharmony_ciconst BufferDecoder = goog.require('protobuf.binary.BufferDecoder'); 7ffe3c632Sopenharmony_ciconst {createBufferDecoder} = goog.require('protobuf.binary.bufferDecoderHelper'); 8ffe3c632Sopenharmony_ci 9ffe3c632Sopenharmony_ci/** 10ffe3c632Sopenharmony_ci * An array of Pairs of float values and their bit representation. 11ffe3c632Sopenharmony_ci * This is used to test encoding and decoding from/to the protobuf wire format. 12ffe3c632Sopenharmony_ci * @return {!Array<{name: string, intValue:number, bufferDecoder: 13ffe3c632Sopenharmony_ci * !BufferDecoder, error: ?boolean, skip_writer: ?boolean}>} 14ffe3c632Sopenharmony_ci */ 15ffe3c632Sopenharmony_cifunction getInt32Pairs() { 16ffe3c632Sopenharmony_ci const int32Pairs = [ 17ffe3c632Sopenharmony_ci { 18ffe3c632Sopenharmony_ci name: 'zero', 19ffe3c632Sopenharmony_ci intValue: 0, 20ffe3c632Sopenharmony_ci bufferDecoder: createBufferDecoder(0x00), 21ffe3c632Sopenharmony_ci }, 22ffe3c632Sopenharmony_ci { 23ffe3c632Sopenharmony_ci name: 'one ', 24ffe3c632Sopenharmony_ci intValue: 1, 25ffe3c632Sopenharmony_ci bufferDecoder: createBufferDecoder(0x01), 26ffe3c632Sopenharmony_ci }, 27ffe3c632Sopenharmony_ci { 28ffe3c632Sopenharmony_ci name: 'minus one', 29ffe3c632Sopenharmony_ci intValue: -1, 30ffe3c632Sopenharmony_ci bufferDecoder: createBufferDecoder(0xFF, 0xFF, 0xFF, 0xFF, 0x0F), 31ffe3c632Sopenharmony_ci // The writer will encode this with 64 bits, see below 32ffe3c632Sopenharmony_ci skip_writer: true, 33ffe3c632Sopenharmony_ci }, 34ffe3c632Sopenharmony_ci { 35ffe3c632Sopenharmony_ci name: 'minus one (64bits)', 36ffe3c632Sopenharmony_ci intValue: -1, 37ffe3c632Sopenharmony_ci bufferDecoder: createBufferDecoder( 38ffe3c632Sopenharmony_ci 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01), 39ffe3c632Sopenharmony_ci }, 40ffe3c632Sopenharmony_ci { 41ffe3c632Sopenharmony_ci name: 'max signed int 2^31 - 1', 42ffe3c632Sopenharmony_ci intValue: Math.pow(2, 31) - 1, 43ffe3c632Sopenharmony_ci bufferDecoder: createBufferDecoder(0xFF, 0xFF, 0xFF, 0xFF, 0x07), 44ffe3c632Sopenharmony_ci 45ffe3c632Sopenharmony_ci }, 46ffe3c632Sopenharmony_ci { 47ffe3c632Sopenharmony_ci name: 'min signed int -2^31', 48ffe3c632Sopenharmony_ci intValue: -Math.pow(2, 31), 49ffe3c632Sopenharmony_ci bufferDecoder: createBufferDecoder(0x80, 0x80, 0x80, 0x80, 0x08), 50ffe3c632Sopenharmony_ci // The writer will encode this with 64 bits, see below 51ffe3c632Sopenharmony_ci skip_writer: true, 52ffe3c632Sopenharmony_ci }, 53ffe3c632Sopenharmony_ci { 54ffe3c632Sopenharmony_ci name: 'value min signed int -2^31 (64 bit)', 55ffe3c632Sopenharmony_ci intValue: -Math.pow(2, 31), 56ffe3c632Sopenharmony_ci bufferDecoder: createBufferDecoder( 57ffe3c632Sopenharmony_ci 0x80, 0x80, 0x80, 0x80, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0x01), 58ffe3c632Sopenharmony_ci }, 59ffe3c632Sopenharmony_ci { 60ffe3c632Sopenharmony_ci name: 'errors out for 11 bytes', 61ffe3c632Sopenharmony_ci intValue: -1, 62ffe3c632Sopenharmony_ci bufferDecoder: createBufferDecoder( 63ffe3c632Sopenharmony_ci 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), 64ffe3c632Sopenharmony_ci error: true, 65ffe3c632Sopenharmony_ci skip_writer: true, 66ffe3c632Sopenharmony_ci }, 67ffe3c632Sopenharmony_ci ]; 68ffe3c632Sopenharmony_ci return [...int32Pairs]; 69ffe3c632Sopenharmony_ci} 70ffe3c632Sopenharmony_ci 71ffe3c632Sopenharmony_ciexports = {getInt32Pairs}; 72