packed_float_test_pairs.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. goog.module('protobuf.binary.packedFloatTestPairs');
  2. const BufferDecoder = goog.require('protobuf.binary.BufferDecoder');
  3. const {createBufferDecoder} = goog.require('protobuf.binary.bufferDecoderHelper');
  4. /**
  5. * An array of Pairs of packed float 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, floatValues: !Array<number>,
  8. * bufferDecoder: !BufferDecoder, skip_writer: ?boolean}>}
  9. */
  10. function getPackedFloatPairs() {
  11. return [
  12. {
  13. name: 'empty value',
  14. floatValues: [],
  15. bufferDecoder: createBufferDecoder(0x00),
  16. skip_writer: true,
  17. },
  18. {
  19. name: 'single value',
  20. floatValues: [1],
  21. bufferDecoder: createBufferDecoder(0x04, 0x00, 0x00, 0x80, 0x3F),
  22. },
  23. {
  24. name: 'multiple values',
  25. floatValues: [1, 0],
  26. bufferDecoder: createBufferDecoder(
  27. 0x08, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00),
  28. },
  29. ];
  30. }
  31. exports = {getPackedFloatPairs};