def test_expect_limits(self) -> None: integers: List[int] = TestUvarint.all_integers buffer: bytes = TestUvarint.all_buffer decoded, total = uvarint.expect(len(integers), buffer, limit=math.inf) self.assertEqual(decoded, integers) self.assertEqual(total, len(buffer)) with self.assertRaises(OverflowError): uvarint.expect(len(integers), buffer)
def test_expect(self) -> None: integers: List[int] = TestUvarint.valid_integers buffer: bytes = TestUvarint.valid_buffer decoded, total = uvarint.expect(len(integers), buffer) self.assertEqual(decoded, integers) self.assertEqual(total, len(buffer))
def test_expect_zero_with_empty_buffer(self) -> None: integers: List[int] bytes_read: int integers, bytes_read = uvarint.expect(0, b'') self.assertEqual(integers, []) self.assertEqual(bytes_read, 0)
def test_expect_zero(self) -> None: integers: List[int] bytes_read: int integers, bytes_read = uvarint.expect(0, TestUvarint.one.uvarint) self.assertEqual(integers, []) self.assertEqual(bytes_read, 0)
def test_expect_more_than_buffer_contains(self) -> None: with self.assertRaises(ValueError): uvarint.expect(2, TestUvarint.one.uvarint)
def test_expect_empty_buffer(self) -> None: with self.assertRaises(ValueError): uvarint.expect(1, b'')