summaryrefslogtreecommitdiff
path: root/tests/test-grammar-integration.cpp
diff options
context:
space:
mode:
authorClint Herron <hanclinto@gmail.com>2024-06-06 06:08:52 -0700
committerGitHub <noreply@github.com>2024-06-06 06:08:52 -0700
commitad675e1c67a05b16e4e12abe30dbecfc808e7b7e (patch)
treee791651be21e9d0ecee87f5cd6f358061de6eb91 /tests/test-grammar-integration.cpp
parenta143c04375828b1f72eb1a326115791b63e79345 (diff)
Added support for . (any character) token in grammar engine. (#6467)
* Added support for . (any characer) token in grammar engine. * Add integration tests for any-character symbol.
Diffstat (limited to 'tests/test-grammar-integration.cpp')
-rw-r--r--tests/test-grammar-integration.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test-grammar-integration.cpp b/tests/test-grammar-integration.cpp
index 9bdab05a..8787fb1e 100644
--- a/tests/test-grammar-integration.cpp
+++ b/tests/test-grammar-integration.cpp
@@ -205,6 +205,33 @@ static void test_complex_grammar() {
);
}
+static void test_special_chars() {
+ // A collection of tests to exercise special characters such as "."
+ test_grammar(
+ "special characters",
+ // Grammar
+ R"""(
+ root ::= ... "abc" ...
+ )""",
+ // Passing strings
+ {
+ "abcabcabc",
+ "aaaabcccc",
+ // NOTE: Also ensures that multi-byte characters still count as a single character
+ "🔵🟠✅abc❌🟠🔵"
+ },
+ // Failing strings
+ {
+ "aaabcccc",
+ "aaaaabcccc",
+ "aaaabccc",
+ "aaaabccccc",
+ "🔵🟠✅❌abc❌✅🟠🔵"
+ "🔵🟠abc🟠🔵"
+ }
+ );
+}
+
static void test_quantifiers() {
// A collection of tests to exercise * + and ? quantifiers
@@ -445,6 +472,7 @@ int main() {
fprintf(stdout, "Running grammar integration tests...\n");
test_simple_grammar();
test_complex_grammar();
+ test_special_chars();
test_quantifiers();
test_failure_missing_root();
test_failure_missing_reference();