tex_render unittest need to debug now...
This commit is contained in:
parent
d393e1e794
commit
ccd388c87c
76
test/test_renders.py
Normal file
76
test/test_renders.py
Normal file
@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
|
||||
import unittest
|
||||
|
||||
from pymath.renders import tex_render, txt_render
|
||||
from pymath.fraction import Fraction
|
||||
from pymath.polynom import Polynom
|
||||
|
||||
|
||||
|
||||
class TestTexRender(unittest.TestCase):
|
||||
"""Testing functions from pymath.renders.tex_render"""
|
||||
|
||||
def test_type_render_int(self):
|
||||
self.assertEqual(tex_render([2]), "2")
|
||||
|
||||
def test_type_render_str(self):
|
||||
self.assertEqual(tex_render(["a"]), "a")
|
||||
|
||||
def test_type_render_fraction(self):
|
||||
self.assertEqual(tex_render([Fraction(1,2)]), "\\frac{ 1 }{ 2 }")
|
||||
|
||||
def test_type_render_polynom(self):
|
||||
self.assertEqual(tex_render([Polynom({"": 1, "x": 3})]), "3x + 1")
|
||||
|
||||
def test_mult_interger(self):
|
||||
exps = [ [2, 3, "*"], [2, -3, "*"], [-2, 3, "*"]]
|
||||
wanted_render = [ "2 \\times 3", "2 \\times ( -3 )", "-2 \\times 3"]
|
||||
for (i,e) in enumerate(exps):
|
||||
rend = tex_render(e)
|
||||
self.assertEqual(rend, wanted_render[i])
|
||||
|
||||
def test_mult_letter(self):
|
||||
exps = [ [2, "a", "*"], ["a", 3, "*"], [-2, "a", "*"], ["a", -2, "*"]]
|
||||
wanted_render = [ "2 a", "3 a", "-2 a", "-2 a"]
|
||||
for (i,e) in enumerate(exps):
|
||||
rend = tex_render(e)
|
||||
self.assertEqual(rend, wanted_render[i])
|
||||
|
||||
def test_mult_fraction(self):
|
||||
exps = [ [2, Fraction(1,2), "*"], [Fraction(1,2), 3, "*"]]
|
||||
wanted_render = [ "2 \\times \\frac{1}{2}", "\\frac{1}{2} \\times 3"]
|
||||
for (i,e) in enumerate(exps):
|
||||
rend = tex_render(e)
|
||||
self.assertEqual(rend, wanted_render[i])
|
||||
|
||||
def test_mult_exp(self):
|
||||
pass
|
||||
|
||||
def test_slash(self):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
class TesttxtRender(unittest.TestCase):
|
||||
"""Testing functions from pymath.renders.txt_render"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
|
Loading…
Reference in New Issue
Block a user