From 1729ef1d24cf6e5f86938f7e5c61775da03c6890 Mon Sep 17 00:00:00 2001 From: Lafrite Date: Sun, 21 Dec 2014 19:13:34 +0100 Subject: [PATCH] add test on eval --- test/test_polynom.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/test_polynom.py b/test/test_polynom.py index 4a80e80..a21ba0a 100644 --- a/test/test_polynom.py +++ b/test/test_polynom.py @@ -7,11 +7,15 @@ import unittest from pymath.polynom import Polynom from pymath.fraction import Fraction from pymath.expression import Expression +from pymath.render import txt class TestPolynom(unittest.TestCase): """Testing functions from pymath.polynom""" + def setup(self): + Expression.set_render(txt) + def test_init(self): p = Polynom([1, 2, 3], "x") @@ -27,8 +31,17 @@ class TestPolynom(unittest.TestCase): def test_deg(self): pass - def test_eval(self): - pass + def test_eval_base(self): + p = Polynom([1, 2]) + self.assertEqual(p(3).simplified(), 7) + + def test_eval_const(self): + p = Polynom([1]) + self.assertEqual(p(3).simplified(), 1) + + def test_eval_const_neg(self): + p = Polynom([-1]) + self.assertEqual(p(3).simplified(), -1) #def test_print(self): # p = Polynom([1,2,3])