Esempio n. 1
0
 def test_is_power_of_two_random_float(self):
     for i in range(RANDOM_TEST_ITERATION):
         random_float = random.random() * random.randint(
             -99999999, 99999999)
         assert bit.is_power_of_two(random_float) == self._is_power_of_two_naive(random_float), \
             'failed to identify power of 2 for {}'.format(random_float)
Esempio n. 2
0
 def test_is_power_of_two_random_true(self):
     for i in range(RANDOM_TEST_ITERATION):
         random_int = random.randint(0, 999999999)
         assert bit.is_power_of_two(2 ** random_int), \
             'failed to identify power of 2 with power = {}'.format(random_int)
Esempio n. 3
0
 def test_is_power_of_two_zero(self):
     assert not bit.is_power_of_two(0)
Esempio n. 4
0
 def test_is_power_of_two_one(self):
     assert bit.is_power_of_two(1)
Esempio n. 5
0
 def test_is_power_of_two_negative(self):
     assert not bit.is_power_of_two(-1)