Skip to content

Commit

Permalink
parsing: Add test for escaped_search_in_between
Browse files Browse the repository at this point in the history
Test for the max_match feature.
  • Loading branch information
Makman2 committed Mar 3, 2015
1 parent 0c11b9e commit 8940000
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions coalib/tests/parsing/StringProcessingTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,93 @@ def test_escaped_search_in_between(self):
self.test_strings[i])
self.assertEqual(expected_results[i], return_value)

# Test the secaped_search_in_between() while variating the max_match
# parameter.
def test_escaped_search_in_between_max_match(self):
begin_sequence = "'"
end_sequence = "'"

# Testing max_match = 1
max_match = 1
expected_results = [
[r"escaped-escape: \\ "],
[r"escaped-quote: \' "],
[r"escaped-anything: \X "],
[r"two escaped escapes: \\\\ "],
[r"escaped-quote at end: \'"],
[r"escaped-escape at end: " + 2 * self.bs],
[r"str1"],
[r"str1"],
[r"str1"],
[r"str1"],
[r"str1"],
[r"str1"],
[r"str1"],
[r"str1"]
]

for i in range(0, len(expected_results)):
# Execute function under test.
return_value = escaped_search_in_between(begin_sequence,
end_sequence,
self.test_strings[i],
max_match)
self.assertEqual(expected_results[i], return_value)

# Testing max_match = 2
max_match = 2
expected_results = [
[r"escaped-escape: \\ "],
[r"escaped-quote: \' "],
[r"escaped-anything: \X "],
[r"two escaped escapes: \\\\ "],
[r"escaped-quote at end: \'"],
[r"escaped-escape at end: " + 2 * self.bs],
[r"str1", r"str2"],
[r"str1", r"str2"],
[r"str1", r"str2"],
[r"str1", r"str2"],
[r"str1", r"str2"],
[r"str1", r"str2"],
[r"str1", r"str2"],
[r"str1", r"str2"]
]

for i in range(0, len(expected_results)):
# Execute function under test.
return_value = escaped_search_in_between(begin_sequence,
end_sequence,
self.test_strings[i],
max_match)
self.assertEqual(expected_results[i], return_value)

# Testing max_match = 10
max_match = 10
expected_results = [
[r"escaped-escape: \\ "],
[r"escaped-quote: \' "],
[r"escaped-anything: \X "],
[r"two escaped escapes: \\\\ "],
[r"escaped-quote at end: \'"],
[r"escaped-escape at end: " + 2 * self.bs],
[r"str1", r"str2"],
[r"str1", r"str2"],
[r"str1", r"str2"],
[r"str1", r"str2"],
[r"str1", r"str2"],
[r"str1", r"str2"],
[r"str1", r"str2"],
[r"str1", r"str2", r"str3"]
]

for i in range(0, len(expected_results)):
# Execute function under test.
return_value = escaped_search_in_between(begin_sequence,
end_sequence,
self.test_strings[i],
max_match)
self.assertEqual(expected_results[i], return_value)

# Test the search_for() function.
def test_search_for(self):
# Match either "out1" or "out2".
Expand Down

0 comments on commit 8940000

Please sign in to comment.