def test_repartition(self): for dummy in range(0, 1000): length = random.randrange(1, 8) blocks = [(index, index, random.randrange(1, 10)) for index in range(0, length)] self.assertTrue(is_contiguous(blocks)) original_blocks = blocks[:] #were_ordered = is_ordered(blocks) #print blocks repartioned = repartition(blocks) #print repartioned self.assertTrue(is_ordered(repartioned)) self.assertTrue(blocks == original_blocks) # Can't assert this anymore. # Trips when in order partitions get merged because they # don't meet the multiple constraint. # #self.assertTrue((were_ordered and blocks == repartioned) or # ((not were_ordered) and blocks != repartioned)) self.assertTrue(is_contiguous(repartioned))
def test_is_contiguous(self): self.assertTrue(is_contiguous(())) self.assertTrue(is_contiguous(((0, 0, '?'), ))) self.assertTrue(is_contiguous(((0, 0, 2), (1, 1, '?')))) self.assertTrue(is_contiguous(((0, 1, 2), (2, 3, '?')))) self.assertFalse(is_contiguous(((0, 0, 2), (2, 2, '?')))) self.assertFalse(is_contiguous(((0, 1, 2), (3, 3, '?'))))
def test_is_contiguous(self): self.assertTrue(is_contiguous( () )) self.assertTrue(is_contiguous( ((0, 0, '?'), ) )) self.assertTrue(is_contiguous( ((0, 0, 2), (1, 1, '?')) )) self.assertTrue(is_contiguous( ((0, 1, 2), (2, 3, '?')) )) self.assertFalse(is_contiguous( ((0, 0, 2), (2, 2, '?')) )) self.assertFalse(is_contiguous( ((0, 1, 2), (3, 3, '?')) ))