packed_double_test_pairs.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. goog.module('protobuf.binary.packedDoubleTestPairs');
  2. const BufferDecoder = goog.require('protobuf.binary.BufferDecoder');
  3. const {createBufferDecoder} = goog.require('protobuf.binary.bufferDecoderHelper');
  4. /**
  5. * An array of Pairs of packed double values and their bit representation.
  6. * This is used to test encoding and decoding from/to the protobuf wire format.
  7. * @return {!Array<{name: string, doubleValues: !Array<number>,
  8. * bufferDecoder: !BufferDecoder, skip_writer: ?boolean}>}
  9. */
  10. function getPackedDoublePairs() {
  11. return [
  12. {
  13. name: 'empty value',
  14. doubleValues: [],
  15. bufferDecoder: createBufferDecoder(0x00),
  16. skip_writer: true,
  17. },
  18. {
  19. name: 'single value',
  20. doubleValues: [1],
  21. bufferDecoder: createBufferDecoder(
  22. 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F),
  23. },
  24. {
  25. name: 'multiple values',
  26. doubleValues: [1, 0],
  27. bufferDecoder: createBufferDecoder(
  28. 0x10, // length
  29. 0x00,
  30. 0x00,
  31. 0x00,
  32. 0x00,
  33. 0x00,
  34. 0x00,
  35. 0xF0,
  36. 0x3F, // 1
  37. 0x00,
  38. 0x00,
  39. 0x00,
  40. 0x00,
  41. 0x00,
  42. 0x00,
  43. 0x00,
  44. 0x00, // 0
  45. ),
  46. },
  47. ];
  48. }
  49. exports = {getPackedDoublePairs};