'Test decoding of repeated fields.'

def testDecodeRepeatedFields(self):

    repeats = (self.REPEATS / 50)
    s = jobs_pb2.MessageList()
    for i in range(self.REPEATS):
        s.job.add(session_id='test', name='foobar', request_id=i)
    test_data = s.SerializeToString()
    def ProtoDecode():
        s = jobs_pb2.MessageList()
        s.ParseFromString(test_data)
        self.assertEqual(s.job[100].request_id, 100)
    def SProtoDecode():
        s = FastGrrMessageList.FromSerializedString(test_data)
        self.assertEqual(s.job[100].request_id, 100)
    self.TimeIt(SProtoDecode, 'SProto    Repeated    Decode', repetitions=repeats)
    self.TimeIt(ProtoDecode, 'Protobuf    Repeated    Decode', repetitions=repeats)
