Skip to content

Commit

Permalink
find_symbol_name_location() : locate symbol name location : start:end
Browse files Browse the repository at this point in the history
  • Loading branch information
kangwonlee committed Dec 26, 2017
1 parent be6c653 commit 185d1d6
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test_symbol_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def test_has_symbol(self):

for k, cell in enumerate(cells):
self.cp.set_cell(cell)
# function under test
cell_result = self.cp.has_symbol()
if cell_result:
result.append((k, cell_result))
Expand Down Expand Up @@ -100,3 +101,49 @@ def test_unit_underline_wrap_bracket(self):
'_{rad}': '[rad]', '_{m_s2}': '[m/s^{2}]', '_{N}': '[N]', '_{deg}': '[deg]', '_{Pa}': '[Pa]',
'_{m2}': '[m^{2}]', '_{m4}': '[m^{4}]', '_{Nm}': '[Nm]', '_{m}': '[m]', '_{N_m}': '[N/m]'}
self.assertDictEqual(expected, result)

def test_find_symbol_name_location_00(self):
# 0 1 2
# 0123456789012345678901234567890123456789012345678901234567890123456789
# 0123456789012345678901234567890123456789012345678901234567890123456789
source_line = "L_AB_m = sy.symbols('L_AB_m', real=True, nonnegative=True)"
result = self.cp.find_symbol_name_location(source_line)
extracted = source_line[result[0]:result[1]]
expected_extracted = 'L_AB_m'

self.assertEqual(expected_extracted, extracted)

def test_find_symbol_name_location_01(self):
# 0 1 2
# 0123456789012345678901234567890123456789012345678901234567890123456789
# 0123456789012345678901234567890123456789012345678901234567890123456789
source_line = "L_AB = sy.symbols('L_AB_m', real=True, nonnegative=True)"
result = self.cp.find_symbol_name_location(source_line)
extracted = source_line[result[0]:result[1]]
expected_extracted = 'L_AB_m'

self.assertEqual(expected_extracted, extracted)


# def test_processor(self):
# file = self.file_processor.read_file()
#
# cells = file['cells']
#
# for k, cell in enumerate(cells):
# self.cp.set_cell(cell)
# # function under test
# self.cp.process_cell()
#
# # begin read processed result
# result = []
#
# for k, cell in enumerate(cells):
# self.cp.set_cell(cell)
# # function under test
# cell_result = self.cp.has_symbol()
# if cell_result:
# result.append((k, cell_result))
#
# # end reading processed result
# self.assertTrue(len(result))

0 comments on commit 185d1d6

Please sign in to comment.