Skip to content

Commit c1b89b8

Browse files
committed
Add integration tests for any-character symbol.
1 parent d0c0083 commit c1b89b8

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

@@ -445,6 +472,7 @@ int main() {
445472
fprintf(stdout, "Running grammar integration tests...\n");
446473
test_simple_grammar();
447474
test_complex_grammar();
475+
test_special_chars();
448476
test_quantifiers();
449477
test_failure_missing_root();
450478
test_failure_missing_reference();

0 commit comments

Comments
Β (0)