mojo/public/tools/mojom/mojom/generate/pack_unittest.py
def testGetVersionInfoComplexOrder(self):
    """Tests pack.GetVersionInfo() using a struct whose definition order,
    ordinal order and pack order for fields are all different.
    """
    struct = mojom.Struct('test')
    struct.AddField(
        'field_3', mojom.BOOL, ordinal=3, attributes={'MinVersion': 3})
    struct.AddField('field_0', mojom.INT32, ordinal=0)
    struct.AddField(
        'field_1', mojom.INT64, ordinal=1, attributes={'MinVersion': 2})
    struct.AddField(
        'field_2', mojom.INT64, ordinal=2, attributes={'MinVersion': 3})
    ps = pack.PackedStruct(struct)

    versions = pack.GetVersionInfo(ps)
    self.assertEqual(3, len(versions))

    self.assertEqual(0, versions[0].version)
    self.assertEqual(1, versions[0].num_fields)
    self.assertEqual(16, versions[0].num_bytes)

    self.assertEqual(2, versions[1].version)
    self.assertEqual(2, versions[1].num_fields)
    self.assertEqual(24, versions[1].num_bytes)

    self.assertEqual(3, versions[2].version)
    self.assertEqual(4, versions[2].num_fields)
    self.assertEqual(32, versions[2].num_bytes)
Tests pack.GetVersionInfo() using a struct whose definition order,
    ordinal order and pack order for fields are all different.
    
Tests pack.GetVersionInfo() using a struct whose definition order,
ordinal order and pack order for fields are all different.
Tests pack . GetVersionInfo () using a struct whose definition order ordinal order and pack order for fields are all different .
def testGetVersionInfoComplexOrder(self):
    struct = mojom.Struct('test')
    struct.AddField(
        'field_3', mojom.BOOL, ordinal=3, attributes={'MinVersion': 3})
    struct.AddField('field_0', mojom.INT32, ordinal=0)
    struct.AddField(
        'field_1', mojom.INT64, ordinal=1, attributes={'MinVersion': 2})
    struct.AddField(
        'field_2', mojom.INT64, ordinal=2, attributes={'MinVersion': 3})
    ps = pack.PackedStruct(struct)
    versions = pack.GetVersionInfo(ps)
    self.assertEqual(3, len(versions))
    self.assertEqual(0, versions[0].version)
    self.assertEqual(1, versions[0].num_fields)
    self.assertEqual(16, versions[0].num_bytes)
    self.assertEqual(2, versions[1].version)
    self.assertEqual(2, versions[1].num_fields)
    self.assertEqual(24, versions[1].num_bytes)
    self.assertEqual(3, versions[2].version)
    self.assertEqual(4, versions[2].num_fields)
    self.assertEqual(32, versions[2].num_bytes)
def testGetVersionInfoComplexOrder ( self ) : struct = mojom . Struct ( 'test' ) struct . AddField ( 'field_3' , mojom . BOOL , ordinal = 3 , attributes = { 'MinVersion' : 3 } ) struct . AddField ( 'field_0' , mojom . INT32 , ordinal = 0 ) struct . AddField ( 'field_1' , mojom . INT64 , ordinal = 1 , attributes = { 'MinVersion' : 2 } ) struct . AddField ( 'field_2' , mojom . INT64 , ordinal = 2 , attributes = { 'MinVersion' : 3 } ) ps = pack . PackedStruct ( struct ) versions = pack . GetVersionInfo ( ps ) self . assertEqual ( 3 , len ( versions ) ) self . assertEqual ( 0 , versions [ 0 ] . version ) self . assertEqual ( 1 , versions [ 0 ] . num_fields ) self . assertEqual ( 16 , versions [ 0 ] . num_bytes ) self . assertEqual ( 2 , versions [ 1 ] . version ) self . assertEqual ( 2 , versions [ 1 ] . num_fields ) self . assertEqual ( 24 , versions [ 1 ] . num_bytes ) self . assertEqual ( 3 , versions [ 2 ] . version ) self . assertEqual ( 4 , versions [ 2 ] . num_fields ) self . assertEqual ( 32 , versions [ 2 ] . num_bytes )
Tests pack.GetVersionInfo() using a struct whose definition order,
ordinal order and pack order for fields are all different.
Tests pack . GetVersionInfo () using a struct whose definition order ordinal order and pack order for fields are all different .
"""Tests pack.GetVersionInfo() using a struct whose definition order,
    ordinal order and pack order for fields are all different.
    """
self