Remove wildcard assert from desugar
This commit is contained in:
parent
77e1a77e02
commit
1fea81b74b
@ -98,20 +98,8 @@ static void desugar_qmark(regex_term_t *term)
|
||||
|
||||
static void desugar_term(regex_term_t *term)
|
||||
{
|
||||
switch (term->type) {
|
||||
case REGEX_TERM_WILDCARD:
|
||||
assert(false);
|
||||
break;
|
||||
|
||||
case REGEX_TERM_SUBEXPR:
|
||||
if (REGEX_TERM_SUBEXPR == term->type)
|
||||
desugar_regex(&term->subexpr);
|
||||
break;
|
||||
|
||||
case REGEX_TERM_CLASS:
|
||||
case REGEX_TERM_LITERAL:
|
||||
case REGEX_TERM_EMPTY:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (term->quantifier) {
|
||||
case REGEX_QUANTIFIER_PLUS:
|
||||
|
@ -32,6 +32,28 @@ static void a_is_unchanged(void)
|
||||
regex_free(&t);
|
||||
}
|
||||
|
||||
static void wildcard_is_unchanged(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;
|
||||
regex_t t = { .count = 1, .capacity = 1, .contents = alternatives };
|
||||
|
||||
desugar_regex(&t);
|
||||
|
||||
ASSERT_EQ(1, t.count);
|
||||
ASSERT_NOT_NULL(t.contents);
|
||||
ASSERT_EQ(1, t.contents[0].count);
|
||||
ASSERT_NOT_NULL(t.contents[0].contents);
|
||||
ASSERT_EQ(REGEX_QUANTIFIER_NONE, t.contents[0].contents[0].quantifier);
|
||||
ASSERT_EQ(REGEX_TERM_WILDCARD, t.contents[0].contents[0].type);
|
||||
|
||||
regex_free(&t);
|
||||
}
|
||||
|
||||
static void abc_is_unchanged(void)
|
||||
{
|
||||
regex_term_t *terms = malloc(3 * sizeof(regex_term_t));
|
||||
@ -327,6 +349,7 @@ int main(void)
|
||||
{
|
||||
TESTING_BEGIN();
|
||||
a_is_unchanged();
|
||||
wildcard_is_unchanged();
|
||||
abc_is_unchanged();
|
||||
a_star_is_unchanged();
|
||||
a_or_b_or_c_is_unchanged();
|
||||
|
Loading…
x
Reference in New Issue
Block a user