def test_itob(self): data = argformats.DelayedArgument('itob:take[:4]:accu[0x1337]:A')() self.assertEqual(data, bytes.fromhex('3713371337133713'))
def test_inc(self): result = argformats.DelayedArgument('take[:5]:inc[8]:e:0x30')(B'') self.assertEqual(result, b'01234')
def test_skip_first_character_of_cyclic_key(self): key = argformats.DelayedArgument('take[1:16]:cycle:KITTY')() self.assertEqual(key, B'ITTYKITTYKITTYK')
def test_skip(self): data = argformats.DelayedArgument('take[:10]:accu[0,5]:A+1')() self.assertEqual(data, bytes(range(5, 15)))
def test_reduce_sum_of_odd_numbers(self): for k in range(1, 56): result = int(argformats.DelayedArgument(F'base[-R]:be:reduce[S+B]:take[:{k}]:accu[1,0]:A+2')(), 0) self.assertEqual(result, k ** 2, F'Failed for {k}.')
def test_accumulator(self): dm = argformats.DelayedArgument('take[:20]:accu[0x45]:(3*A+3)&0xFF')() self.assertEqual(dm, bytes.fromhex('D2796E4DEAC146D582899EDD9AD176653299CE6D'))
def test_no_yara_in_other_handlers(self): self.assertEqual(argformats.DelayedArgument('yara:??')(), B'yara:??')