diff --git a/FizzBuzz.py b/FizzBuzz.py new file mode 100644 index 0000000..4c0c5da --- /dev/null +++ b/FizzBuzz.py @@ -0,0 +1,8 @@ +def transform(num): + if num % 3 == 0 and num % 5 == 0: + return "FizzBuzz" + elif num % 3 == 0: + return "Fizz" + elif num % 5 == 0: + return "Buzz" + return str(num) diff --git a/TestFizzBuzz.py b/TestFizzBuzz.py new file mode 100644 index 0000000..5b766e4 --- /dev/null +++ b/TestFizzBuzz.py @@ -0,0 +1,16 @@ +import unittest +from FizzBuzz import transform + + +class TestFizzBuzz(unittest.TestCase): + def test_input_normal(self): + self.assertEqual(transform(1), "1") + + def test_input_times_3(self): + self.assertEqual(transform(3), "Fizz") + + def test_input_times_5(self): + self.assertEqual(transform(5), "Buzz") + + def test_input_times_3_and_times_5(self): + self.assertEqual(transform(15), "FizzBuzz")