def test_poly_five(self): """Test the construction of a fifth order polynomial.""" p_five = func.Polynomial([(0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1)]) self.assertEqual(p_five(0), 1) self.assertEqual(p_five(1), 6) self.assertEqual(p_five(-1), 0)
def test_poly_properform(self): """Test that the polynomial class will combine like terms.""" f_x = func.Polynomial([(7, 3.5), (7, 6.5)]) g_x = func.Polynomial([(7, 10)]) self.assertEqual(f_x, g_x)
def test_poly_equalitytrue(self): """Test that equal polynomials evaluate to equal.""" f_x = func.Polynomial([(0, 1), (3, 5)]) g_x = func.Polynomial([(3, 5), (0, 1)]) self.assertEqual(f_x, g_x)
def test_poly_one(self): """Test the construction of a first order polynomial.""" p_one = func.Polynomial([(0, 0), (1, 5)]) self.assertEqual(p_one(0), 0) self.assertEqual(p_one(1), 5) self.assertEqual(p_one(-1), -5)
def test_poly_zero(self): """Test the construction of a zero-th order polynomial.""" p_zero = func.Polynomial([(0, 3)]) self.assertEqual(p_zero(0), 3) self.assertEqual(p_zero(1), 3) self.assertEqual(p_zero(-1), 3)