packed_bool_test_pairs.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. goog.module('protobuf.binary.packedBoolTestPairs');
  2. const BufferDecoder = goog.require('protobuf.binary.BufferDecoder');
  3. const {createBufferDecoder} = goog.require('protobuf.binary.bufferDecoderHelper');
  4. /**
  5. * An array of Pairs of packed bool 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, boolValues: !Array<boolean>,
  8. * bufferDecoder: !BufferDecoder, skip_writer: ?boolean}>}
  9. */
  10. function getPackedBoolPairs() {
  11. return [
  12. {
  13. name: 'empty value',
  14. boolValues: [],
  15. bufferDecoder: createBufferDecoder(0x00),
  16. skip_writer: true,
  17. },
  18. {
  19. name: 'single value',
  20. boolValues: [true],
  21. bufferDecoder: createBufferDecoder(0x01, 0x01),
  22. },
  23. {
  24. name: 'single multi-bytes value',
  25. boolValues: [true],
  26. bufferDecoder: createBufferDecoder(0x02, 0x80, 0x01),
  27. skip_writer: true,
  28. },
  29. {
  30. name: 'multiple values',
  31. boolValues: [true, false],
  32. bufferDecoder: createBufferDecoder(0x02, 0x01, 0x00),
  33. },
  34. {
  35. name: 'multiple multi-bytes values',
  36. boolValues: [true, false],
  37. bufferDecoder: createBufferDecoder(
  38. 0x0C, // length
  39. 0x80,
  40. 0x80,
  41. 0x80,
  42. 0x80,
  43. 0x80,
  44. 0x01, // true
  45. 0x80,
  46. 0x80,
  47. 0x80,
  48. 0x80,
  49. 0x80,
  50. 0x00, // false
  51. ),
  52. skip_writer: true,
  53. },
  54. ];
  55. }
  56. exports = {getPackedBoolPairs};