Skip to content

Commit

Permalink
StringProcessing: position_is_escaped() test
Browse files Browse the repository at this point in the history
Adds a test that uses the class defined test-strings. The old test only
uses a custom single test string.

Fixes #464.
  • Loading branch information
Makman2 committed Apr 27, 2015
1 parent 1ff5556 commit 25e2644
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions coalib/tests/parsing/StringProcessingTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,38 @@ def test_position_is_escaped(self):
for position, value in result_dict.items():
self.assertEqual(position_is_escaped(test_string, position), value)

# Test the position_is_escaped() with more test strings from this class.
def test_position_is_escaped_advanced(self):
expected_results = [
30 * [False] + [True] + 7 * [False],
30 * [False] + [True] + 7 * [False],
30 * [False] + [True] + 7 * [False],
28 * [False] + [True, False, True] + 7 * [False],
31 * [False] + [True] + 6 * [False],
31 * [False] + [True] + 6 * [False],
38 * [False],
6 * [False] + [True] + 31 * [False],
6 * [False] + [True, False, True] + 29 * [False],
6 * [False] + [True] + 31 * [False],
6 * [False] + [True, False, True] + 29 * [False],
14 * [False] + [True] + 23 * [False],
12 * [False] + [True, False, True] + 23 * [False],
38 * [False],
[],
14 * [False],
[False],
[False, True]]

results = [[position_is_escaped(test_string, i)
for i in range(len(test_string))]
for test_string in self.test_strings]

zipped = [zip(x, y) for x, y in zip(expected_results, results)]
flattened = [item for sublist in zipped for item in sublist]

for elem in flattened:
self.assertEqual(elem[0], elem[1])

if __name__ == '__main__':
unittest.main(verbosity=2)

0 comments on commit 25e2644

Please sign in to comment.