Skip to content

Commit

Permalink
Unit tests: Added regex choice
Browse files Browse the repository at this point in the history
  • Loading branch information
noamgat committed Oct 30, 2023
1 parent cd54a72 commit ab10e0b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_regexparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,19 @@ def test_any_character():
string=f'ab{character * num_repeats}123',
regex='ab.+123',
expect_success=expect_success)



def test_dates():
# https://stackoverflow.com/q/15491894 , removed the ^ and $ because interegular doesn't support them
date_regex = r'(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}'
_test_regex_parsing_with_string('01/01/2020', date_regex, True)
_test_regex_parsing_with_string('29/04/1986', date_regex, True)
_test_regex_parsing_with_string('001/01/2020', date_regex, False)
_test_regex_parsing_with_string('001/01/2020', date_regex, False)


def test_string_choice():
choice_regex = r'abc|def|ghi'
_test_regex_parsing_with_string('abc', choice_regex, True)
_test_regex_parsing_with_string('def', choice_regex, True)
_test_regex_parsing_with_string('ghi', choice_regex, True)
_test_regex_parsing_with_string('aei', choice_regex, False)

0 comments on commit ab10e0b

Please sign in to comment.