Skip to content

Instantly share code, notes, and snippets.

@herberthamaral
Created May 24, 2018 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herberthamaral/0ae974cb045d3fc19f6879cd3c728bea to your computer and use it in GitHub Desktop.
Save herberthamaral/0ae974cb045d3fc19f6879cd3c728bea to your computer and use it in GitHub Desktop.
Dojo com fizzbuzz
import unittest
def fizzbuzz(num):
retorno = ''
if num == 0:
return retorno
if num % 3 == 0:
retorno = 'fizz'
if num % 5 == 0:
retorno += 'buzz'
return retorno
class TestCase(unittest.TestCase):
def test_is_empty(self):
self.assertEqual(fizzbuzz(0), '')
def test_fizz_quando_divisivel_por_3(self):
self.assertEqual(fizzbuzz(3), 'fizz')
def test_vazio_quando_nao_divisivel(self):
self.assertEqual(fizzbuzz(4), '')
def test_buzz_quando_divisivel_por_5(self):
self.assertEqual(fizzbuzz(5), 'buzz')
def test_fizzbuzz_quando_por_5_e_3(self):
self.assertEqual(fizzbuzz(15), 'fizzbuzz')
def test_fizz_quando_negativo(self):
self.assertEqual(fizzbuzz(-3), 'fizz')
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment