Skip to content

Commit

Permalink
added more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kangwonlee committed Dec 26, 2017
1 parent 3c4d0d9 commit 4ddfd34
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions test_symbol_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,6 @@ def test_has_symbol(self):

self.assertSequenceEqual(expected, result)

def test_replace_symbol(self):
self.maxDiff = None
file = self.file_processor.read_file()
cells = file['cells']
result = []

for k, cell in enumerate(cells):
self.cp.set_cell(cell)
cell_result = self.cp.has_symbol()
if cell_result:
result.append((k, cell_result))

# compare with an expected list
expected = [
(8, [{'line number': 0, 'source': "L_AB_m = sy.symbols('L_{AB}[m]', real=True, nonnegative=True)"}]),
(10, [{'line number': 0, 'source': "w0_N_m = sy.symbols('w0[N/m]', real=True)"}]),
(12, [{'line number': 0, 'source': "E_Pa, I_m4 = sy.symbols('E[Pa], I[m^{4}]', positive=True)"}]),
(14, [{'line number': 0, 'source': "x_m = sy.symbols('x[m]', nonnegative=True)"}]),
(16, [{'line number': 0,
'source': "R_A_N, M_A_Nm, R_B_N = sy.symbols('R_{A}[N], M_{A}[Nm], R_{B}[N]', real=True)"}])]

self.assertSequenceEqual(expected, result)


class MyLineConverterTesterBase(unittest.TestCase):
def setUp(self):
Expand Down Expand Up @@ -250,5 +227,23 @@ def test_process_line_10(self):
"w0_N_m = sy.Symbol('w0[N/m]', real=True)")

def test_process_line_11(self):
self.check_process_line("w0_N_m = sy.Symbol('w0_N_m', real=True)",
"w0_N_m = sy.Symbol('w0[N/m]', real=True)")
self.check_process_line("w0_N = sy.Symbol('w0_N_m', real=True)",
"w0_N = sy.Symbol('w0[N/m]', real=True)")


class TestSymbolConverter01(MyLineConverterTesterBase):
def test_process_line_00(self):
self.check_process_line("E_Pa, I_m4 = sy.symbols('E_Pa, I_m4', positive=True)",
"E_Pa, I_m4 = sy.symbols('E[Pa], I[m^{4}]', positive=True)")

def test_process_line_01(self):
self.check_process_line("E, I = sy.symbols('E_Pa, I_m4', positive=True)",
"E, I = sy.symbols('E[Pa], I[m^{4}]', positive=True)")

def test_process_line_10(self):
self.check_process_line("x_m = sy.symbols('x_m', nonnegative=True)",
"x_m = sy.symbols('x[m]', nonnegative=True)")

def test_process_line_20(self):
self.check_process_line("R_A_N, M_A_Nm, R_B_N = sy.symbols('R_A_N, M_A_Nm, R_B_N', real=True)",
"R_A_N, M_A_Nm, R_B_N = sy.symbols('R_{A}[N], M_{A}[Nm], R_{B}[N]', real=True)")

0 comments on commit 4ddfd34

Please sign in to comment.