~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-06 16:29:12 UTC
  • mto: This revision was merged to the branch mainline in revision 1869.
  • Revision ID: john@arbash-meinel.com-20060706162912-1680b115cdb24071
[merge] Johan Rydberg test updates

Show diffs side-by-side

added added

removed removed

Lines of Context:
429
429
        # and in the worst case, use bzrlib.user_encoding
430
430
        self.assertEqual('user_encoding', osutils.get_terminal_encoding())
431
431
 
 
432
 
 
433
class TestOffsets(TestCase):
 
434
    """Test test_offsets_to_ranges method that is used to convert
 
435
    readv into combined ranges."""
 
436
 
 
437
    def test_offsets_to_http_ranges(self):
 
438
        ranges, tail = osutils.offsets_to_http_ranges([(10, 1), (20, 2), (22, 5)])
 
439
        self.assertEquals(tuple(ranges[0]), (10, 10))
 
440
        self.assertEquals(tuple(ranges[1]), (20, 26))
 
441
        self.assertEquals(tail, 0)
 
442
 
 
443
        ranges, tail = osutils.offsets_to_http_ranges([(10, 1), (11, 2), (22, 5), (-4, 4)])
 
444
        self.assertEquals(tuple(ranges[0]), (10, 12))
 
445
        self.assertEquals(tuple(ranges[1]), (22, 26))
 
446
        self.assertEquals(tail, 4)
 
447
 
 
448
        ranges, tail = osutils.offsets_to_http_ranges([(-4, 4), (-8, 8)])
 
449
        self.assertEquals(tuple(ranges), ())
 
450
        self.assertEquals(tail, 8)
 
451
 
 
452
        ranges, tail = osutils.offsets_to_http_ranges([(10, 1), (20, 2)], fudge_factor=9)
 
453
        self.assertEquals(tuple(ranges[0]), (10, 21))
 
454
        self.assertEquals(len(ranges), 1)
 
455
        self.assertEquals(tail, 0)
 
456
 
 
457
        ranges, tail = osutils.offsets_to_http_ranges([(10, 1), (20, 2)], fudge_factor=8)
 
458
        self.assertEquals(tuple(ranges[0]), (10, 10))
 
459
        self.assertEquals(tuple(ranges[1]), (20, 21))
 
460
        self.assertEquals(tail, 0)
 
461
 
 
462
 
 
463