How to use the aioquic.quic.rangeset.RangeSet function in aioquic

To help you get started, we’ve selected a few aioquic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aiortc / aioquic / tests / test_rangeset.py View on Github external
def test_subtract_split(self):
        rangeset = RangeSet()
        rangeset.add(0, 10)
        rangeset.subtract(2, 5)
        self.assertEqual(list(rangeset), [range(0, 2), range(5, 10)])
github aiortc / aioquic / tests / test_rangeset.py View on Github external
def test_eq(self):
        r0 = RangeSet([range(0, 1)])
        r1 = RangeSet([range(1, 2), range(3, 4)])
        r2 = RangeSet([range(3, 4), range(1, 2)])

        self.assertTrue(r0 == r0)
        self.assertFalse(r0 == r1)
        self.assertFalse(r0 == 0)

        self.assertTrue(r1 == r1)
        self.assertFalse(r1 == r0)
        self.assertTrue(r1 == r2)
        self.assertFalse(r1 == 0)

        self.assertTrue(r2 == r2)
        self.assertTrue(r2 == r1)
        self.assertFalse(r2 == r0)
        self.assertFalse(r2 == 0)
github aiortc / aioquic / tests / test_rangeset.py View on Github external
def test_add_single_reverse(self):
        rangeset = RangeSet()

        rangeset.add(2)
        self.assertEqual(list(rangeset), [range(2, 3)])

        rangeset.add(1)
        self.assertEqual(list(rangeset), [range(1, 3)])

        rangeset.add(0)
        self.assertEqual(list(rangeset), [range(0, 3)])
github aiortc / aioquic / tests / test_rangeset.py View on Github external
def test_len(self):
        rangeset = RangeSet()
        self.assertEqual(len(rangeset), 0)

        rangeset = RangeSet([range(0, 1)])
        self.assertEqual(len(rangeset), 1)
github aiortc / aioquic / tests / test_rangeset.py View on Github external
def test_add_range_merge(self):
        rangeset = RangeSet()

        rangeset.add(0, 2)
        self.assertEqual(list(rangeset), [range(0, 2)])

        rangeset.add(3, 5)
        self.assertEqual(list(rangeset), [range(0, 2), range(3, 5)])

        rangeset.add(2, 3)
        self.assertEqual(list(rangeset), [range(0, 5)])
github aiortc / aioquic / tests / test_rangeset.py View on Github external
def test_pop(self):
        rangeset = RangeSet([range(1, 2), range(3, 4)])
        r = rangeset.shift()
        self.assertEqual(r, range(1, 2))
        self.assertEqual(list(rangeset), [range(3, 4)])
github aiortc / aioquic / tests / test_rangeset.py View on Github external
def test_eq(self):
        r0 = RangeSet([range(0, 1)])
        r1 = RangeSet([range(1, 2), range(3, 4)])
        r2 = RangeSet([range(3, 4), range(1, 2)])

        self.assertTrue(r0 == r0)
        self.assertFalse(r0 == r1)
        self.assertFalse(r0 == 0)

        self.assertTrue(r1 == r1)
        self.assertFalse(r1 == r0)
        self.assertTrue(r1 == r2)
        self.assertFalse(r1 == 0)

        self.assertTrue(r2 == r2)
        self.assertTrue(r2 == r1)
        self.assertFalse(r2 == r0)
        self.assertFalse(r2 == 0)
github aiortc / aioquic / tests / test_rangeset.py View on Github external
def test_add_range_ordered(self):
        rangeset = RangeSet()

        rangeset.add(0, 2)
        self.assertEqual(list(rangeset), [range(0, 2)])

        rangeset.add(2, 4)
        self.assertEqual(list(rangeset), [range(0, 4)])

        rangeset.add(4, 6)
        self.assertEqual(list(rangeset), [range(0, 6)])
github aiortc / aioquic / tests / test_recovery.py View on Github external
packet_number=0,
            packet_type=PACKET_TYPE_ONE_RTT,
            sent_bytes=1280,
            sent_time=123.45,
        )
        space = self.ONE_RTT_SPACE

        #  packet sent
        self.recovery.on_packet_sent(packet, space)
        self.assertEqual(self.recovery.bytes_in_flight, 1280)
        self.assertEqual(space.ack_eliciting_in_flight, 0)
        self.assertEqual(len(space.sent_packets), 1)

        # packet ack'd
        self.recovery.on_ack_received(
            space, ack_rangeset=RangeSet([range(0, 1)]), ack_delay=0.0, now=10.0
        )
        self.assertEqual(self.recovery.bytes_in_flight, 0)
        self.assertEqual(space.ack_eliciting_in_flight, 0)
        self.assertEqual(len(space.sent_packets), 0)

        # check RTT
        self.assertFalse(self.recovery._rtt_initialized)
        self.assertEqual(self.recovery._rtt_latest, 0.0)
        self.assertEqual(self.recovery._rtt_min, math.inf)
        self.assertEqual(self.recovery._rtt_smoothed, 0.0)
github aiortc / aioquic / tests / test_rangeset.py View on Github external
def test_subtract_no_change(self):
        rangeset = RangeSet()
        rangeset.add(5, 10)
        rangeset.add(15, 20)
        rangeset.add(25, 30)

        rangeset.subtract(0, 5)
        self.assertEqual(list(rangeset), [range(5, 10), range(15, 20), range(25, 30)])

        rangeset.subtract(10, 15)
        self.assertEqual(list(rangeset), [range(5, 10), range(15, 20), range(25, 30)])