Example #1
0
    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)
Example #2
0
	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)
Example #3
0
    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))
Example #4
0
	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))
Example #5
0
 def test_seven(self):
     self.assertEqual(set([1, 2, 3, 5, 7]), backups_to_keep(7))
Example #6
0
 def test_four(self):
     self.assertEqual(set([1, 2, 4]), backups_to_keep(4))
Example #7
0
 def test_one(self):
     self.assertEqual(set([1]), backups_to_keep(1))
Example #8
0
 def test_zero(self):
     self.assertEqual(set(), backups_to_keep(0))
Example #9
0
	def test_seven(self):
		self.assertEqual(set([1, 2, 3, 5, 7]), backups_to_keep(7))
Example #10
0
	def test_four(self):
		self.assertEqual(set([1, 2, 4]), backups_to_keep(4))
Example #11
0
	def test_one(self):
		self.assertEqual(set([1]), backups_to_keep(1))
Example #12
0
	def test_zero(self):
		self.assertEqual(set(), backups_to_keep(0))