def test_addVarTupleSeq_with_single_element_tuples(self): w = Writer() w.addVarTupleSeq([[1], [9], [12]], 2, 3) self.assertEqual(bytearray( b'\x00\x00\x06' + # length b'\x00\x01' + # 1st element b'\x00\x09' + # 2nd element b'\x00\x0c'), w.bytes)
def test_addVarTupleSeq(self): w = Writer() w.addVarTupleSeq([(1, 2), (2, 9)], 1, 2) self.assertEqual(bytearray( b'\x00\x04' + # length b'\x01\x02' + # first tuple b'\x02\x09' # second tuple ), w.bytes)
def test_addVarTupleSeq_with_double_byte_overflowing_data(self): w = Writer() with self.assertRaises(ValueError): w.addVarTupleSeq([(1, 2), (3, 0x10000)], 2, 2)
def test_addVarTupleSeq_with_double_byte_invalid_sized_tuples(self): w = Writer() with self.assertRaises(ValueError): w.addVarTupleSeq([(1, 2), (2, 3, 4)], 2, 2)
def test_addVarTupleSeq_with_overflowing_data(self): w = Writer() with self.assertRaises(ValueError): w.addVarTupleSeq([(1, 2), (2, 256)], 1, 2)
def test_addVarTupleSeq_with_empty_array(self): w = Writer() w.addVarTupleSeq([], 1, 2) self.assertEqual(bytearray( b'\x00\x00'), w.bytes)
def test_addVarTupleSeq_with_empty_array(self): w = Writer() w.addVarTupleSeq([], 1, 2) self.assertEqual(bytearray(b'\x00\x00'), w.bytes)