source/projects/calf/tests/python/test_grammar.py

32 lines
564 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
2021-05-15 17:34:32 +00:00
@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',
],
)
2021-04-09 07:16:16 +00:00
def test_match_string(ex):
assert re.fullmatch(cg.STRING_PATTERN, ex)