Support wildcards in construct
This commit is contained in:
@@ -53,6 +53,31 @@ static void test_empty_expression(void)
|
||||
fsa_free(&fsa);
|
||||
}
|
||||
|
||||
static void test_wildcard(void)
|
||||
{
|
||||
regex_term_t *terms = malloc(1 * sizeof(regex_term_t));
|
||||
terms[0].quantifier = REGEX_QUANTIFIER_NONE;
|
||||
terms[0].type = REGEX_TERM_WILDCARD;
|
||||
regex_sequence_t *alternatives = malloc(1 * sizeof(regex_sequence_t));
|
||||
alternatives[0].count = alternatives[0].capacity = 1;
|
||||
alternatives[0].contents = terms;
|
||||
const regex_t regex
|
||||
= { .count = 1, .capacity = 1, .contents = alternatives };
|
||||
|
||||
fsa_t fsa;
|
||||
construct_nfa(®ex, &fsa);
|
||||
|
||||
ASSERT_TRUE(accepts(&fsa, "a"));
|
||||
ASSERT_TRUE(accepts(&fsa, "b"));
|
||||
ASSERT_TRUE(accepts(&fsa, "c"));
|
||||
ASSERT_TRUE(accepts(&fsa, "d"));
|
||||
ASSERT_FALSE(accepts(&fsa, ""));
|
||||
ASSERT_FALSE(accepts(&fsa, "aa"));
|
||||
|
||||
regex_free(®ex);
|
||||
fsa_free(&fsa);
|
||||
}
|
||||
|
||||
static void test_literal_expression(void)
|
||||
{
|
||||
regex_term_t *terms = malloc(1 * sizeof(regex_term_t));
|
||||
@@ -386,6 +411,7 @@ int main(void)
|
||||
// Base cases
|
||||
test_empty_expression();
|
||||
test_literal_expression();
|
||||
test_wildcard();
|
||||
test_sequence();
|
||||
test_union();
|
||||
test_star();
|
||||
|
||||
Reference in New Issue
Block a user