def test_factorial_of_neg():
    n = -1
    ans = None
    assert factorial.factorial_recursion(n) == ans
    assert factorial.factorial_recursion_memo(n) == ans
    assert factorial.factorial_iter(n) == ans
def test_factorial_of_zero():
    n = 0
    assert factorial.factorial_recursion(n) == 1
    assert factorial.factorial_recursion_memo(n) == 1
    assert factorial.factorial_iter(n) == 1
Beispiel #3
0
 def test_the_one_case(self):
     '''
 make sure than 1! = 1
 '''
     self.assertEqual(factorial_while(1), 1)
     self.assertEqual(factorial_recursion(1), 1)
def test_factorial_of_10():
    n = 10
    ans = 3628800
    assert factorial.factorial_recursion(n) == ans
    assert factorial.factorial_recursion_memo(n) == ans
    assert factorial.factorial_iter(n) == ans
Beispiel #5
0
 def test_the_zero_case(self):
     '''
 make sure that both implementations accurately report that 0! = 1
 '''
     self.assertEqual(factorial_recursion(0), 1)
     self.assertEqual(factorial_while(0), 1)
Beispiel #6
0
 def test_negative_case(self):
     '''
 make sure that a negative case evaluates to false
 '''
     self.assertFalse(factorial_recursion(-3))
     self.assertFalse(factorial_while(-3))
Beispiel #7
0
 def test_factorial_recursion_is_working(self):
     '''
 make sure that 4! = 24 for the recursion implementation
 '''
     self.assertEqual(factorial_recursion(4), 24)
 def test_the_one_case(self):
   '''
   make sure than 1! = 1
   '''
   self.assertEqual(factorial_while(1), 1)
   self.assertEqual(factorial_recursion(1), 1)
 def test_negative_case(self):
   '''
   make sure that a negative case evaluates to false
   '''
   self.assertFalse(factorial_recursion(-3))
   self.assertFalse(factorial_while(-3))
 def test_the_zero_case(self):
   '''
   make sure that both implementations accurately report that 0! = 1
   '''
   self.assertEqual(factorial_recursion(0), 1)
   self.assertEqual(factorial_while(0), 1)
 def test_factorial_recursion_is_working(self):
   '''
   make sure that 4! = 24 for the recursion implementation
   '''
   self.assertEqual(factorial_recursion(4), 24)