adapt test to float number in render and str2tokens

This commit is contained in:
Benjamin Bertrand 2016-02-13 20:10:51 +03:00
parent b5d383a4be
commit f968a25345
2 changed files with 9 additions and 6 deletions

View File

@ -38,6 +38,9 @@ class TestTexRender(unittest.TestCase):
def test_type_render_str(self):
self.assertEqual(tex(["a"]), "a")
def test_type_render_float(self):
self.assertEqual(tex([12.345]), "12.345")
def test_type_render_fraction(self):
self.assertEqual(tex([Fraction(1, 2)]), "\\frac{ 1 }{ 2 }")
@ -214,6 +217,9 @@ class TesttxtRender(unittest.TestCase):
def test_type_render_str(self):
self.assertEqual(txt(["a"]), "a")
def test_type_render_float(self):
self.assertEqual(txt([12.345]), "12.345")
def test_type_render_fraction(self):
self.assertEqual(txt([Fraction(1, 2)]), "1 / 2")

View File

@ -18,6 +18,9 @@ class TestStr2tokens(unittest.TestCase):
ans = str2in_tokens("2*3+4")
self.assertEqual(ans, [2, "*", 3, "+", 4])
ans = str2in_tokens("2.34")
self.assertEqual(ans, [2.34])
def test_in2post_fix(self):
in_tokens = str2in_tokens("2+3*4")
ans = in2post_fix(in_tokens)
@ -27,8 +30,6 @@ class TestStr2tokens(unittest.TestCase):
ans = in2post_fix(in_tokens)
self.assertEqual(ans, [2, 3, "*", 4, "+"])
# TODO: Ajouter des tests pour les cas particuliers... |sam. nov. 8
# 17:39:18 CET 2014
def test_str2in_tokens_big_num(self):
exp = "123 + 3"
tok = str2in_tokens(exp)
@ -65,10 +66,6 @@ class TestStr2tokens(unittest.TestCase):
tok = str2in_tokens(exp)
self.assertEqual(tok, [-3, "*", "(", 2, ")"])
def test_str2tokens_error_float(self):
exp = "1 + 1.3"
self.assertRaises(ValueError, str2tokens, exp)
def test_str2tokens_error(self):
exp = "1 + $"
self.assertRaises(ValueError, str2tokens, exp)