sint64_test_pairs.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * @fileoverview Test data for sint64 encoding and decoding.
  3. */
  4. goog.module('protobuf.binary.sint64TestPairs');
  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 float 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, error: ?boolean, skip_writer: ?boolean}>}
  13. */
  14. function getSint64Pairs() {
  15. const sint64Pairs = [
  16. {
  17. name: 'zero',
  18. longValue: Int64.fromInt(0),
  19. bufferDecoder: createBufferDecoder(0x00),
  20. },
  21. {
  22. name: 'one ',
  23. longValue: Int64.fromInt(1),
  24. bufferDecoder: createBufferDecoder(0x02),
  25. },
  26. {
  27. name: 'minus one',
  28. longValue: Int64.fromInt(-1),
  29. bufferDecoder: createBufferDecoder(0x01),
  30. },
  31. {
  32. name: 'two',
  33. longValue: Int64.fromInt(2),
  34. bufferDecoder: createBufferDecoder(0x04),
  35. },
  36. {
  37. name: 'minus two',
  38. longValue: Int64.fromInt(-2),
  39. bufferDecoder: createBufferDecoder(0x03),
  40. },
  41. {
  42. name: 'min value',
  43. longValue: Int64.getMinValue(),
  44. bufferDecoder: createBufferDecoder(
  45. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01),
  46. },
  47. {
  48. name: 'max value',
  49. longValue: Int64.getMaxValue(),
  50. bufferDecoder: createBufferDecoder(
  51. 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01),
  52. },
  53. ];
  54. return [...sint64Pairs];
  55. }
  56. exports = {getSint64Pairs};