mojo/public/tools/mojom/mojom/generate/pack_unittest.py
def _CheckPackSequence(self, kinds, fields, offsets):
    """Checks the pack order and offsets of a sequence of mojom.Kinds.

    Args:
      kinds: A sequence of mojom.Kinds that specify the fields that are to be
      created.
      fields: The expected order of the resulting fields, with the integer "1"
      first.
      offsets: The expected order of offsets, with the integer "0" first.
    """
    struct = mojom.Struct('test')
    index = 1
    for kind in kinds:
      struct.AddField('%d' % index, kind)
      index += 1
    ps = pack.PackedStruct(struct)
    num_fields = len(ps.packed_fields)
    self.assertEqual(len(kinds), num_fields)
    for i in range(num_fields):
      self.assertEqual('%d' % fields[i], ps.packed_fields[i].field.mojom_name)
      self.assertEqual(offsets[i], ps.packed_fields[i].offset)
Checks the pack order and offsets of a sequence of mojom.Kinds.

    Args:
      kinds: A sequence of mojom.Kinds that specify the fields that are to be
      created.
      fields: The expected order of the resulting fields, with the integer "1"
      first.
      offsets: The expected order of offsets, with the integer "0" first.
    
Checks the pack order and offsets of a sequence of mojom.Kinds.
Args:
kinds: A sequence of mojom.Kinds that specify the fields that are to be
created.
fields: The expected order of the resulting fields, with the integer "1"
first.
offsets: The expected order of offsets, with the integer "0" first.
Checks the pack order and offsets of a sequence of mojom . Kinds . Args : kinds : A sequence of mojom . Kinds that specify the fields that are to be created . fields : The expected order of the resulting fields with the integer " 1 " first . offsets : The expected order of offsets with the integer " 0 " first .
def _CheckPackSequence(self, kinds, fields, offsets):
    struct = mojom.Struct('test')
    index = 1
    for kind in kinds:
      struct.AddField('%d' % index, kind)
      index += 1
    ps = pack.PackedStruct(struct)
    num_fields = len(ps.packed_fields)
    self.assertEqual(len(kinds), num_fields)
    for i in range(num_fields):
      self.assertEqual('%d' % fields[i], ps.packed_fields[i].field.mojom_name)
      self.assertEqual(offsets[i], ps.packed_fields[i].offset)
def _CheckPackSequence ( self , kinds , fields , offsets ) : struct = mojom . Struct ( 'test' ) index = 1 for kind in kinds : struct . AddField ( '%d' % index , kind ) index += 1 ps = pack . PackedStruct ( struct ) num_fields = len ( ps . packed_fields ) self . assertEqual ( len ( kinds ) , num_fields ) for i in range ( num_fields ) : self . assertEqual ( '%d' % fields [ i ] , ps . packed_fields [ i ] . field . mojom_name ) self . assertEqual ( offsets [ i ] , ps . packed_fields [ i ] . offset )
Checks the pack order and offsets of a sequence of mojom.Kinds.
Checks the pack order and offsets of a sequence of mojom . Kinds .
"""Checks the pack order and offsets of a sequence of mojom.Kinds.

    Args:
      kinds: A sequence of mojom.Kinds that specify the fields that are to be
      created.
      fields: The expected order of the resulting fields, with the integer "1"
      first.
      offsets: The expected order of offsets, with the integer "0" first.
    """
self
kinds
fields
offsets