Ejemplo n.º 1
0
 def setUp(self):
     self.number = Number(4)
     self.number2 = Number(10)
     self.number3 = Number(7)
Ejemplo n.º 2
0
class TestNumberInformation(unittest.TestCase):

    def setUp(self):
        self.number = Number(4)
        self.number2 = Number(10)
        self.number3 = Number(7)

    def test_if_number_is_even_or_odd(self):
        self.number.even_odd() |should| equal_to('even')
        self.number2.even_odd() |should| equal_to('even')
        self.number3.even_odd() |should| equal_to('odd')

    def it_returns_number_in_roman(self):
        self.number.roman() |should| equal_to('IV')
        self.number2.roman() |should| equal_to('X')
        self.number3.roman() |should| equal_to('VII')
        Number(108).roman() |should| equal_to('CVIII')

    def test_term_fibonacci(self):
        self.number.fibonacci() |should| equal_to([0 ,1 ,1 ,2])
        self.number3.fibonacci() |should| equal_to([0, 1, 1, 2, 3, 5, 8])

    def test_looping_factorial(self):
        self.number.looping_factorial() |should| equal_to(24)
        self.number3.looping_factorial() |should| equal_to(5040)
        Number(0).looping_factorial() |should| equal_to(1)

    def test_resursive_factorial(self):
        self.number.resursive_factorial() |should| equal_to(24)
        self.number3.resursive_factorial() |should| equal_to(5040)
        Number(0).resursive_factorial() |should| equal_to(1)

    def test_funcional_factorial(self):
        self.number.funcional_factorial() |should| equal_to(24)
        self.number3.funcional_factorial() |should| equal_to(5040)
        Number(0).funcional_factorial() |should| equal_to(1)