Merge branch 'unittest' into polynom
This commit is contained in:
commit
09ceb07f41
@ -2,34 +2,26 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
from pymath import arithmetic
|
from pymath import arithmetic
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestArithmetic(unittest.TestCase):
|
def test_gcd_commu():
|
||||||
"""Testing functions from pymath.arithmetic"""
|
assert arithmetic.gcd(3, 15) == arithmetic.gcd(15,3)
|
||||||
|
|
||||||
def test_gcd_commu(self):
|
def test_gcd1():
|
||||||
self.assertEqual(arithmetic.gcd(3, 15), arithmetic.gcd(15,3))
|
assert arithmetic.gcd(3, 15) == 3
|
||||||
|
|
||||||
def test_gcd1(self):
|
def test_gcd2():
|
||||||
self.assertEqual(arithmetic.gcd(3, 15), 3)
|
assert arithmetic.gcd(14, 21) == 7
|
||||||
|
|
||||||
def test_gcd2(self):
|
def test_gcd_prem():
|
||||||
self.assertEqual(arithmetic.gcd(14, 21), 7)
|
assert arithmetic.gcd(14, 19) == 1
|
||||||
|
|
||||||
def test_gcd_prem(self):
|
def test_gcd_neg():
|
||||||
self.assertEqual(arithmetic.gcd(14, 19), 1)
|
assert arithmetic.gcd(3, -15) == 3
|
||||||
|
assert arithmetic.gcd(-3, -15) == -3
|
||||||
|
|
||||||
def test_gcd_neg(self):
|
|
||||||
self.assertEqual(arithmetic.gcd(3, -15), 3)
|
|
||||||
self.assertEqual(arithmetic.gcd(-3, -15), -3)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,11 +11,12 @@ from pymath.generic import first_elem
|
|||||||
from pymath.render import txt, tex
|
from pymath.render import txt, tex
|
||||||
|
|
||||||
|
|
||||||
Expression.set_render(txt)
|
|
||||||
|
|
||||||
class TestExpression(unittest.TestCase):
|
class TestExpression(unittest.TestCase):
|
||||||
"""Testing functions from pymath.expression"""
|
"""Testing functions from pymath.expression"""
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
Expression.set_render(txt)
|
||||||
|
|
||||||
def test_init_from_str(self):
|
def test_init_from_str(self):
|
||||||
exp = Expression("2 + 3")
|
exp = Expression("2 + 3")
|
||||||
self.assertEqual(exp.postfix_tokens, [2, 3, "+"])
|
self.assertEqual(exp.postfix_tokens, [2, 3, "+"])
|
||||||
|
Loading…
Reference in New Issue
Block a user