def test_multiple_values(self): self.assertEqual( decode([ 0xC0, 0x0, 0xC8, 0xE8, 0x56, 0xFF, 0xFF, 0xFF, 0x7F, 0x0, 0xFF, 0x7F, 0x81, 0x80, 0x0, ]), [0x2000, 0x123456, 0xFFFFFFF, 0x0, 0x3FFF, 0x4000], )
def test_incomplete_sequence_causes_error_even_if_value_is_zero(self): with self.assertRaisesWithMessage(ValueError): decode([0x80])
def test_incomplete_sequence_causes_error(self): with self.assertRaises(ValueError): decode([0xff])
def test_multiple_values(self): self.assertEqual( decode([ 0xc0, 0x0, 0xc8, 0xe8, 0x56, 0xff, 0xff, 0xff, 0x7f, 0x0, 0xff, 0x7f, 0x81, 0x80, 0x0 ]), [0x2000, 0x123456, 0xfffffff, 0x0, 0x3fff, 0x4000])
def test_maximum_32_bit_integer(self): self.assertEqual(decode([0x8F, 0xFF, 0xFF, 0xFF, 0x7F]), [0xFFFFFFFF])
def test_one_byte(self): self.assertEqual(decode([0x7f]), [0x7f])
def test_three_bytes(self): self.assertEqual(decode([0xFF, 0xFF, 0x7F]), [0x1FFFFF])
def test_maximum_32_bit_integer(self): self.assertEqual(decode([0x8f, 0xff, 0xff, 0xff, 0x7f]), [0xffffffff])
def test_incomplete_sequence_causes_error(self): with self.assertRaisesWithMessage(ValueError): decode([0xff])
def test_four_bytes(self): self.assertEqual(decode([0x81, 0x80, 0x80, 0x0]), [0x200000])
def test_three_bytes(self): self.assertEqual(decode([0xff, 0xff, 0x7f]), [0x1fffff])
def test_two_bytes(self): self.assertEqual(decode([0xc0, 0x0]), [0x2000])
def test_one_byte(self): self.assertEqual(decode([0x7F]), [0x7F])
def test_multiple_values(self): self.assertEqual( decode([0xc0, 0x0, 0xc8, 0xe8, 0x56, 0xff, 0xff, 0xff, 0x7f, 0x0, 0xff, 0x7f, 0x81, 0x80, 0x0]), [0x2000, 0x123456, 0xfffffff, 0x0, 0x3fff, 0x4000] )
def test_two_bytes(self): self.assertEqual(decode([0xC0, 0x0]), [0x2000])
def test_incomplete_sequence_causes_error(self): with self.assertRaisesWithMessage(ValueError): decode([0xFF])
def test_incomplete_sequence_causes_error_even_if_value_is_zero(self): with self.assertRaises(ValueError) as err: decode([0x80]) self.assertEqual(type(err.exception), ValueError) self.assertEqual(err.exception.args[0], "incomplete sequence")