def test_spacing_incremental(self): state = set() for n in range(1, 10000): state = set([1] + [i + 1 for i in state]) f = backups_to_keep(max(state)) state &= f # If the algorithm is applied incrementally, the state of # the backups should be identical to the state recommended by # the backups_to_keep function. self.assertEqual(f, state)
def test_spacing_incremental(self): state = set() for n in range(1, 10000): state = set([1] + [i+1 for i in state]) f = backups_to_keep(max(state)) state &= f # If the algorithm is applied incrementally, the state of # the backups should be identical to the state recommended by # the backups_to_keep function. self.assertEqual(f, state)
def test_spacing(self): for n in range(3, 10000): r = backups_to_keep(n) # Always keep the oldest backup self.assertTrue(n in r) # Always keep the newest backup self.assertTrue(1 in r) # Number of backups is always between log2(n) and 2*log2(n) self.assertGreaterEqual(len(r), log(n, 2)) self.assertLess(len(r), 2 * log(n, 2))
def test_spacing(self): for n in range(3, 10000): r = backups_to_keep(n) # Always keep the oldest backup self.assertTrue(n in r) # Always keep the newest backup self.assertTrue(1 in r) # Number of backups is always between log2(n) and 2*log2(n) self.assertGreaterEqual(len(r), log(n, 2)) self.assertLess(len(r), 2*log(n, 2))
def test_seven(self): self.assertEqual(set([1, 2, 3, 5, 7]), backups_to_keep(7))
def test_four(self): self.assertEqual(set([1, 2, 4]), backups_to_keep(4))
def test_one(self): self.assertEqual(set([1]), backups_to_keep(1))
def test_zero(self): self.assertEqual(set(), backups_to_keep(0))