Skip to content

Commit 9e30513

Browse files
committed
Add integration tests for any-character symbol.
1 parent 774e9f5 commit 9e30513

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

β€Žtests/test-grammar-integration.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,33 @@ static void test_complex_grammar() {
205205
);
206206
}
207207

208+
static void test_special_chars() {
209+
// A collection of tests to exercise special characters such as "."
210+
test_grammar(
211+
"special characters",
212+
// Grammar
213+
R"""(
214+
root ::= ... "abc" ...
215+
)""",
216+
// Passing strings
217+
{
218+
"abcabcabc",
219+
"aaaabcccc",
220+
// NOTE: Also ensures that multi-byte characters still count as a single character
221+
"πŸ”΅πŸŸ βœ…abcβŒπŸŸ πŸ”΅"
222+
},
223+
// Failing strings
224+
{
225+
"aaabcccc",
226+
"aaaaabcccc",
227+
"aaaabccc",
228+
"aaaabccccc",
229+
"πŸ”΅πŸŸ βœ…βŒabcβŒβœ…πŸŸ πŸ”΅"
230+
"πŸ”΅πŸŸ abcπŸŸ πŸ”΅"
231+
}
232+
);
233+
}
234+
208235
static void test_quantifiers() {
209236
// A collection of tests to exercise * + and ? quantifiers
210237

@@ -369,6 +396,7 @@ int main() {
369396
fprintf(stdout, "Running grammar integration tests...\n");
370397
test_simple_grammar();
371398
test_complex_grammar();
399+
test_special_chars();
372400
test_quantifiers();
373401
test_failure_missing_root();
374402
test_failure_missing_reference();

0 commit comments

Comments
Β (0)