2020-07-04 22:56:49 +08:00
|
|
|
import unittest
|
2017-02-14 19:19:21 +08:00
|
|
|
|
|
|
|
|
2020-07-04 22:56:49 +08:00
|
|
|
class TestFizzBuzz(unittest.TestCase):
|
2017-02-14 19:19:21 +08:00
|
|
|
|
|
|
|
def test_fizz_buzz(self):
|
|
|
|
solution = Solution()
|
2020-07-04 22:56:49 +08:00
|
|
|
self.assertRaises(TypeError, solution.fizz_buzz, None)
|
|
|
|
self.assertRaises(ValueError, solution.fizz_buzz, 0)
|
2017-02-14 19:19:21 +08:00
|
|
|
expected = [
|
|
|
|
'1',
|
|
|
|
'2',
|
|
|
|
'Fizz',
|
|
|
|
'4',
|
|
|
|
'Buzz',
|
|
|
|
'Fizz',
|
|
|
|
'7',
|
|
|
|
'8',
|
|
|
|
'Fizz',
|
|
|
|
'Buzz',
|
|
|
|
'11',
|
|
|
|
'Fizz',
|
|
|
|
'13',
|
|
|
|
'14',
|
|
|
|
'FizzBuzz'
|
|
|
|
]
|
2020-07-04 22:56:49 +08:00
|
|
|
self.assertEqual(solution.fizz_buzz(15), expected)
|
2017-02-14 19:19:21 +08:00
|
|
|
print('Success: test_fizz_buzz')
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
test = TestFizzBuzz()
|
|
|
|
test.test_fizz_buzz()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-07-04 22:56:49 +08:00
|
|
|
main()
|