コード例 #1
0
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
コード例 #2
0
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
コード例 #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)
コード例 #4
0
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
コード例 #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)
コード例 #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))
コード例 #7
0
 def test_factorial_recursion_is_working(self):
     '''
 make sure that 4! = 24 for the recursion implementation
 '''
     self.assertEqual(factorial_recursion(4), 24)
コード例 #8
0
 def test_the_one_case(self):
   '''
   make sure than 1! = 1
   '''
   self.assertEqual(factorial_while(1), 1)
   self.assertEqual(factorial_recursion(1), 1)
コード例 #9
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))
コード例 #10
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)
コード例 #11
0
 def test_factorial_recursion_is_working(self):
   '''
   make sure that 4! = 24 for the recursion implementation
   '''
   self.assertEqual(factorial_recursion(4), 24)