From 892ff89a66d78f121984768d6bfc2c69ffb49a1b Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sun, 3 Nov 2024 11:54:34 +0000 Subject: [PATCH] Add integration test using negated class --- tests/integration_tests.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/integration_tests.c b/tests/integration_tests.c index da2ea4b..aee8245 100644 --- a/tests/integration_tests.c +++ b/tests/integration_tests.c @@ -74,6 +74,19 @@ static void test_system_header_include_regex(void) fsa_free(&dfa); } +static void test_quoted_string_regex(void) +{ + fsa_t dfa; + const char *regex = "'(\\\\'|[^'])*'"; + const bool success = compile(regex, strlen(regex), &dfa); + ASSERT_TRUE(success); + ASSERT_ACCEPTS(&dfa, "''"); + ASSERT_ACCEPTS(&dfa, "'foo bar baz'"); + ASSERT_ACCEPTS(&dfa, "'foo \\'bar\\' baz'"); + ASSERT_REJECTS(&dfa, "'foo 'bar' baz'"); + fsa_free(&dfa); +} + int main(void) { TESTING_BEGIN(); @@ -82,5 +95,6 @@ int main(void) test_arbitrary_regex_1(); test_arbitrary_regex_2(); test_system_header_include_regex(); + test_quoted_string_regex(); return TESTING_END(); }