fixed32_test_pairs.js 1018 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @fileoverview Test data for float encoding and decoding.
  3. */
  4. goog.module('protobuf.binary.fixed32TestPairs');
  5. const BufferDecoder = goog.require('protobuf.binary.BufferDecoder');
  6. const {createBufferDecoder} = goog.require('protobuf.binary.bufferDecoderHelper');
  7. /**
  8. * An array of Pairs of float values and their bit representation.
  9. * This is used to test encoding and decoding from/to the protobuf wire format.
  10. * @return {!Array<{name: string, intValue: number, bufferDecoder:
  11. * !BufferDecoder}>}
  12. */
  13. function getFixed32Pairs() {
  14. const fixed32Pairs = [
  15. {
  16. name: 'zero',
  17. intValue: 0,
  18. bufferDecoder: createBufferDecoder(0x00, 0x00, 0x00, 0x00),
  19. },
  20. {
  21. name: 'one ',
  22. intValue: 1,
  23. bufferDecoder: createBufferDecoder(0x01, 0x00, 0x00, 0x00)
  24. },
  25. {
  26. name: 'max int 2^32 -1',
  27. intValue: Math.pow(2, 32) - 1,
  28. bufferDecoder: createBufferDecoder(0xFF, 0xFF, 0xFF, 0xFF)
  29. },
  30. ];
  31. return [...fixed32Pairs];
  32. }
  33. exports = {getFixed32Pairs};