def testHashTheSameAfterReset(self):
     container = Pad(pad_length=10 * 8, fields=String('abc'), pad_data='\xff')
     hash_after_creation = container.hash()
     container.mutate()
     hash_after_mutate = container.hash()
     self.assertEqual(hash_after_creation, hash_after_mutate)
     container.reset()
     hash_after_reset = container.hash()
     self.assertEqual(hash_after_creation, hash_after_reset)
     while container.mutate():
         hash_after_mutate_all = container.hash()
         self.assertEqual(hash_after_creation, hash_after_mutate_all)
         container.render()
         hash_after_render_all = container.hash()
         self.assertEqual(hash_after_creation, hash_after_render_all)
 def testHashTheSameAfterReset(self):
     container = Pad(pad_length=10 * 8, fields=String('abc'), pad_data='\xff')
     hash_after_creation = container.hash()
     container.mutate()
     hash_after_mutate = container.hash()
     self.assertEqual(hash_after_creation, hash_after_mutate)
     container.reset()
     hash_after_reset = container.hash()
     self.assertEqual(hash_after_creation, hash_after_reset)
     while container.mutate():
         hash_after_mutate_all = container.hash()
         self.assertEqual(hash_after_creation, hash_after_mutate_all)
         container.render()
         hash_after_render_all = container.hash()
         self.assertEqual(hash_after_creation, hash_after_render_all)
 def testFixedWithoutPad(self):
     data = 'abcdefghijklmnop'
     expected = Bits(bytes=data)
     uut = Pad(pad_length=10 * 8, fields=Static(data), pad_data='\xff')
     uut_num_mutations = uut.num_mutations()
     self.assertEqual(uut_num_mutations, 0)
     actual_num_mutations = 0
     while uut.mutate():
         actual_num_mutations += 1
     self.assertEqual(actual_num_mutations, uut_num_mutations)
     self.assertEqual(uut.render(), expected)
 def testNumMutations(self):
     field = String(name='padded', value='abc')
     uut = Pad(self.pad_length, fields=field, name='uut')
     field_num_mutations = field.num_mutations()
     uut_num_mutations = uut.num_mutations()
     self.assertEqual(uut_num_mutations, field_num_mutations)
     self.assertGreater(uut_num_mutations, 0)
     actual_num_mutations = 0
     while uut.mutate():
         actual_num_mutations += 1
     self.assertEqual(actual_num_mutations, uut_num_mutations)
 def testFixedWithoutPad(self):
     data = 'abcdefghijklmnop'
     expected = Bits(bytes=data)
     uut = Pad(pad_length=10 * 8, fields=Static(data), pad_data='\xff')
     uut_num_mutations = uut.num_mutations()
     self.assertEqual(uut_num_mutations, 0)
     actual_num_mutations = 0
     while uut.mutate():
         actual_num_mutations += 1
     self.assertEqual(actual_num_mutations, uut_num_mutations)
     self.assertEqual(uut.render(), expected)
 def testNumMutations(self):
     field = String(name='padded', value='abc')
     uut = Pad(self.pad_length, fields=field, name=self.uut_name)
     field_num_mutations = field.num_mutations()
     uut_num_mutations = uut.num_mutations()
     self.assertEqual(uut_num_mutations, field_num_mutations)
     self.assertGreater(uut_num_mutations, 0)
     actual_num_mutations = 0
     while uut.mutate():
         actual_num_mutations += 1
     self.assertEqual(actual_num_mutations, uut_num_mutations)
 def testPadWhenFuzzable(self):
     field = String(name='padded', value='abc')
     uut = Pad(self.pad_length, fields=field, name='uut')
     self._testValuePadded(field, uut, self.pad_length, '\x00')
     while uut.mutate():
         self._testValuePadded(field, uut, self.pad_length, '\x00')
 def testPadWhenFuzzable(self):
     field = String(name='padded', value='abc')
     uut = Pad(self.pad_length, fields=field, name=self.uut_name)
     self._testValuePadded(field, uut, self.pad_length, '\x00')
     while uut.mutate():
         self._testValuePadded(field, uut, self.pad_length, '\x00')