sfixed64_test_pairs.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @fileoverview Test data for sfixed32 encoding and decoding.
  3. */
  4. goog.module('protobuf.binary.sfixed64TestPairs');
  5. const BufferDecoder = goog.require('protobuf.binary.BufferDecoder');
  6. const Int64 = goog.require('protobuf.Int64');
  7. const {createBufferDecoder} = goog.require('protobuf.binary.bufferDecoderHelper');
  8. /**
  9. * An array of Pairs of int values and their bit representation.
  10. * This is used to test encoding and decoding from/to the protobuf wire format.
  11. * @return {!Array<{name: string, longValue: !Int64, bufferDecoder:
  12. * !BufferDecoder}>}
  13. */
  14. function getSfixed64Pairs() {
  15. const sfixed64Pairs = [
  16. {
  17. name: 'zero',
  18. longValue: Int64.fromInt(0),
  19. bufferDecoder:
  20. createBufferDecoder(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
  21. },
  22. {
  23. name: 'one',
  24. longValue: Int64.fromInt(1),
  25. bufferDecoder:
  26. createBufferDecoder(0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
  27. },
  28. {
  29. name: 'minus one',
  30. longValue: Int64.fromInt(-1),
  31. bufferDecoder:
  32. createBufferDecoder(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
  33. },
  34. {
  35. name: 'max int 2^63 -1',
  36. longValue: Int64.getMaxValue(),
  37. bufferDecoder:
  38. createBufferDecoder(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F)
  39. },
  40. {
  41. name: 'min int -2^63',
  42. longValue: Int64.getMinValue(),
  43. bufferDecoder:
  44. createBufferDecoder(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80)
  45. },
  46. ];
  47. return [...sfixed64Pairs];
  48. }
  49. exports = {getSfixed64Pairs};