• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * @fileoverview Test data for int32 encoding and decoding.
3 */
4goog.module('protobuf.binary.sint32TestPairs');
5
6const BufferDecoder = goog.require('protobuf.binary.BufferDecoder');
7const {createBufferDecoder} = goog.require('protobuf.binary.bufferDecoderHelper');
8
9/**
10 * An array of Pairs of float values and their bit representation.
11 * This is used to test encoding and decoding from/to the protobuf wire format.
12 * @return {!Array<{name: string, intValue:number, bufferDecoder:
13 *     !BufferDecoder, error: ?boolean, skip_writer: ?boolean}>}
14 */
15function getSint32Pairs() {
16  const sint32Pairs = [
17    {
18      name: 'zero',
19      intValue: 0,
20      bufferDecoder: createBufferDecoder(0x00),
21    },
22    {
23      name: 'one ',
24      intValue: 1,
25      bufferDecoder: createBufferDecoder(0x02),
26    },
27    {
28      name: 'minus one',
29      intValue: -1,
30      bufferDecoder: createBufferDecoder(0x01),
31    },
32    {
33      name: 'two',
34      intValue: 2,
35      bufferDecoder: createBufferDecoder(0x04),
36    },
37    {
38      name: 'minus two',
39      intValue: -2,
40      bufferDecoder: createBufferDecoder(0x03),
41    },
42    {
43      name: 'int 2^31 - 1',
44      intValue: Math.pow(2, 31) - 1,
45      bufferDecoder: createBufferDecoder(0xFE, 0xFF, 0xFF, 0xFF, 0x0F),
46
47    },
48    {
49      name: '-2^31',
50      intValue: -Math.pow(2, 31),
51      bufferDecoder: createBufferDecoder(0xFF, 0xFF, 0xFF, 0xFF, 0x0F),
52    },
53  ];
54  return [...sint32Pairs];
55}
56
57exports = {getSint32Pairs};
58