|
# -*- coding: utf-8 -*- |
|
#!/usr/bin/env python |
|
|
|
|
|
import unittest |
|
|
|
from fizzgame import FizzGame |
|
|
|
class TestFizzGame(unittest.TestCase): |
|
|
|
def test_get_transform(self): |
|
game = FizzGame([2, 5, 7]) |
|
self.assertEqual(game.get_transform(2), 'Fizz') |
|
self.assertEqual(game.get_transform(5), 'Buzz') |
|
self.assertEqual(game.get_transform(7), 'Whizz') |
|
self.assertEqual(game.get_transform(10), 'FizzBuzz') |
|
self.assertEqual(game.get_transform(20), 'Fizz') |
|
self.assertEqual(game.get_transform(28), 'Fizz') |
|
self.assertEqual(game.get_transform(35), 'BuzzWhizz') |
|
self.assertEqual(game.get_transform(70), 'FizzBuzzWhizz') |
|
game = FizzGame([2, 3, 7]) |
|
self.assertEqual(game.get_transform(42), 'Fizz') |
|
|
|
def test_full_result(self): |
|
nums = (3, 5, 7) |
|
game = FizzGame(nums) |
|
result = game.get_result() |
|
sample = [1, 2, 'Fizz', 4, 'Buzz', 'Fizz', 'Whizz', 8, 'Fizz', 'Buzz', 11, 'Fizz', 'Fizz', |
|
'Whizz', 'FizzBuzz', 16, 17, 'Fizz', 19, 'Buzz', 'FizzWhizz', 22, 'Fizz', 'Fizz', |
|
'Buzz', 26, 'Fizz', 'Whizz', 29, 'Fizz', 'Fizz', 'Fizz', 'Fizz', 'Fizz', 'Fizz', |
|
'Fizz', 'Fizz', 'Fizz', 'Fizz', 'Buzz', 41, 'FizzWhizz', 'Fizz', 44, 'FizzBuzz', |
|
46, 47, 'Fizz', 'Whizz', 'Buzz', 'Fizz', 52, 'Fizz', 'Fizz', 'Buzz', 'Whizz', |
|
'Fizz', 58, 59, 'FizzBuzz', 61, 62, 'Fizz', 64, 'Buzz', 'Fizz', 67, 68, 'Fizz', |
|
'BuzzWhizz', 71, 'Fizz', 'Fizz', 74, 'FizzBuzz', 76, 'Whizz', 'Fizz', 79, 'Buzz', |
|
'Fizz', 82, 'Fizz', 'FizzWhizz', 'Buzz', 86, 'Fizz', 88, 89, 'FizzBuzz', 'Whizz', |
|
92, 'Fizz', 94, 'Buzz', 'Fizz', 97, 'Whizz', 'Fizz', 'Buzz'] |
|
self.assertEqual(result, sample) |
|
|
|
|
|
if __name__ == '__main__': |
|
unittest.main() |