add test on eval

This commit is contained in:
Lafrite 2014-12-21 19:13:34 +01:00
parent 108c794a04
commit 1729ef1d24

View File

@ -7,11 +7,15 @@ import unittest
from pymath.polynom import Polynom from pymath.polynom import Polynom
from pymath.fraction import Fraction from pymath.fraction import Fraction
from pymath.expression import Expression from pymath.expression import Expression
from pymath.render import txt
class TestPolynom(unittest.TestCase): class TestPolynom(unittest.TestCase):
"""Testing functions from pymath.polynom""" """Testing functions from pymath.polynom"""
def setup(self):
Expression.set_render(txt)
def test_init(self): def test_init(self):
p = Polynom([1, 2, 3], "x") p = Polynom([1, 2, 3], "x")
@ -27,8 +31,17 @@ class TestPolynom(unittest.TestCase):
def test_deg(self): def test_deg(self):
pass pass
def test_eval(self): def test_eval_base(self):
pass 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): #def test_print(self):
# p = Polynom([1,2,3]) # p = Polynom([1,2,3])