mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-05 08:58:02 +00:00
Add add digits challenge
This commit is contained in:
29
math_probability/add_digits/test_add_digits.py
Normal file
29
math_probability/add_digits/test_add_digits.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from nose.tools import assert_equal, assert_raises
|
||||
|
||||
|
||||
class TestAddDigits(object):
|
||||
|
||||
def test_add_digits(self, func):
|
||||
assert_raises(TypeError, func, None)
|
||||
assert_raises(ValueError, func, -1)
|
||||
assert_equal(func(0), 0)
|
||||
assert_equal(func(9), 9)
|
||||
assert_equal(func(138), 3)
|
||||
assert_equal(func(65536), 7)
|
||||
print('Success: test_add_digits')
|
||||
|
||||
|
||||
def main():
|
||||
test = TestAddDigits()
|
||||
solution = Solution()
|
||||
test.test_add_digits(solution.add_digits)
|
||||
try:
|
||||
test.test_add_digits(solution.add_digits_optimized)
|
||||
except NameError:
|
||||
# Alternate solutions are only defined
|
||||
# in the solutions file
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user