• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * @fileoverview Test data for sfixed32 encoding and decoding.
3 */
4goog.module('protobuf.binary.sfixed32TestPairs');
5
6const BufferDecoder = goog.require('protobuf.binary.BufferDecoder');
7const {createBufferDecoder} = goog.require('protobuf.binary.bufferDecoderHelper');
8
9/**
10 * An array of Pairs of int 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}>}
14 */
15function getSfixed32Pairs() {
16  const sfixed32Pairs = [
17    {
18      name: 'zero',
19      intValue: 0,
20      bufferDecoder: createBufferDecoder(0x00, 0x00, 0x00, 0x00),
21    },
22    {
23      name: 'one',
24      intValue: 1,
25      bufferDecoder: createBufferDecoder(0x01, 0x00, 0x00, 0x00)
26    },
27    {
28      name: 'minus one',
29      intValue: -1,
30      bufferDecoder: createBufferDecoder(0xFF, 0xFF, 0xFF, 0xFF),
31    },
32    {
33      name: 'max int 2^31 -1',
34      intValue: Math.pow(2, 31) - 1,
35      bufferDecoder: createBufferDecoder(0xFF, 0xFF, 0xFF, 0x7F)
36    },
37    {
38      name: 'min int -2^31',
39      intValue: -Math.pow(2, 31),
40      bufferDecoder: createBufferDecoder(0x00, 0x00, 0x00, 0x80)
41    },
42  ];
43  return [...sfixed32Pairs];
44}
45
46exports = {getSfixed32Pairs};
47