source/projects/calf/tests/test_grammar.py

31 lines
495 B
Python
Raw Normal View History

2021-04-09 07:16:16 +00:00
"""
Tests covering the Calf grammar.
"""
import re
from calf import grammar as cg
from conftest import parametrize
@parametrize('ex', [
# Proper strings
'""',
'"foo bar"',
'"foo\n bar\n\r qux"',
'"foo\\"bar"',
'""""""',
'"""foo bar baz"""',
'"""foo "" "" "" bar baz"""',
# Unterminated string cases
'"',
'"f',
'"foo bar',
'"foo\\" bar',
'"""foo bar baz',
])
def test_match_string(ex):
assert re.fullmatch(cg.STRING_PATTERN, ex)