mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-05 00:48:03 +00:00
Add power two challenge
This commit is contained in:
23
math_probability/power_two/test_is_power_of_two.py
Normal file
23
math_probability/power_two/test_is_power_of_two.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from nose.tools import assert_equal, assert_raises
|
||||
|
||||
|
||||
class TestSolution(object):
|
||||
|
||||
def test_is_power_of_two(self):
|
||||
solution = Solution()
|
||||
assert_raises(TypeError, solution.is_power_of_two, None)
|
||||
assert_equal(solution.is_power_of_two(0), False)
|
||||
assert_equal(solution.is_power_of_two(1), True)
|
||||
assert_equal(solution.is_power_of_two(2), True)
|
||||
assert_equal(solution.is_power_of_two(15), False)
|
||||
assert_equal(solution.is_power_of_two(16), True)
|
||||
print('Success: test_is_power_of_two')
|
||||
|
||||
|
||||
def main():
|
||||
test = TestSolution()
|
||||
test.test_is_power_of_two()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user