source/projects/calf/tests/python/test_grammar.py
2021-05-15 11:34:32 -06:00

31 lines
564 B
Python

"""
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)