コード例 #1
0
    def test_collatz_step(self):
        # you should probably write some tests to determine if collatz_step is
        # being correctly computed
	self.assertEqual(collatz_step(1), 1)
	self.assertEqual(collatz_step(3), 10)
	self.assertEqual(collatz_step(2), 1)
	self.assertEqual(collatz_step(5), 16)
	self.assertEqual(collatz_step(4), 2)
コード例 #2
0
 def test_collatz_step(self):
     # you should probably write some tests to determine if collatz_step is
     # being correctly computed
     # test even case
     m = collatz_step(20)
     self.assertEqual(m, 10)
     # test odd cade
     k = collatz_step(5)
     self.assertEqual(k, 16)
コード例 #3
0
    def test_collatz_step(self):
        # you should probably write some tests to determine if collatz_step is
        
	# test even case	
	m = collatz_step(2);
	self.assertEqual(1, m)
	
	# test odd case
	m = collatz_step(5);
	self.assertEqual(16,m)
コード例 #4
0
    def test_collatz_step_error(self):
        # this test has been written for you. it demonstrates how to test if a
        # function raises an error
        with self.assertRaises(ValueError):
            collatz_step(-1)
            collatz_step(-2)
	    collatz_step(-2.5)
	with self.assertRaises(TypeError):
	    collatz_step(1.0)
コード例 #5
0
 def test_collatz_step_error(self):
     with self.assertRaises(ValueError):
         collatz_step(-1)
         collatz_step(-2)
         collatz_step(-19)
コード例 #6
0
 def test_collatz_step_one(self):
     self.assertEqual(collatz_step(1), 1)
コード例 #7
0
 def test_collatz_step(self):
     self.assertEqual(collatz_step(5), 16)
     self.assertEqual(collatz_step(16), 8)
     self.assertEqual(collatz_step(97), 292)
コード例 #8
0
 def test_collatz_step_error(self):
     with self.assertRaises(ValueError):
         collatz_step(-1)
         collatz_step(-2)
         collatz_step(-19)
コード例 #9
0
 def test_collatz_step_one(self):
     self.assertEqual(collatz_step(1), 1)
コード例 #10
0
 def test_collatz_step(self):
     self.assertEqual(collatz_step(5), 16)
     self.assertEqual(collatz_step(16), 8)
     self.assertEqual(collatz_step(97), 292)
コード例 #11
0
 def test_collatz_step_one(self):
     # you should probably write a test to see if collatz_step handles the
     # n=1 case correctly
     self.assertEquals(collatz_step(1), 1)
コード例 #12
0
 def test_collatz_step(self):
     # you should probably write some tests to determine if collatz_step is
     # being correctly computed
     m = collatz_step(5)
     self.assertEqual(m, 16)
コード例 #13
0
 def test_collatz_step_error(self):
     
     # function raises an error
     with self.assertRaises(ValueError):
         collatz_step(-1)
         collatz_step(-2)
コード例 #14
0
 def test_collatz_step_one(self):
    
     # n=1 case correctly
     m = collatz_step(1);
     self.assertEqual(1,m)