Implement star construction
This commit is contained in:
@@ -132,6 +132,30 @@ static void test_union(void)
|
||||
fsa_free(&fsa);
|
||||
}
|
||||
|
||||
static void test_star(void)
|
||||
{
|
||||
regex_term_t *terms = malloc(1 * sizeof(regex_term_t));
|
||||
terms[0].quantifier = REGEX_QUANTIFIER_STAR;
|
||||
terms[0].type = REGEX_TERM_LITERAL;
|
||||
terms[0].literal = 'a';
|
||||
regex_sequence_t *alternatives = malloc(1 * sizeof(regex_sequence_t));
|
||||
alternatives[0].count = alternatives[0].capacity = 1;
|
||||
alternatives[0].contents = terms;
|
||||
regex_t regex = { .count = 1, .capacity = 1, .contents = alternatives };
|
||||
|
||||
fsa_t fsa;
|
||||
construct(®ex, &fsa);
|
||||
|
||||
const fsa_state_t *initial = &fsa.states[fsa.initial];
|
||||
ASSERT_TRUE(initial->final);
|
||||
ASSERT_EQ(1, initial->count);
|
||||
ASSERT_EQ('a', initial->rules[0].input);
|
||||
ASSERT_EQ(fsa.initial, initial->rules[0].next);
|
||||
|
||||
regex_free(®ex);
|
||||
fsa_free(&fsa);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
TESTING_BEGIN();
|
||||
@@ -139,5 +163,6 @@ int main(void)
|
||||
test_literal_expression();
|
||||
test_sequence();
|
||||
test_union();
|
||||
test_star();
|
||||
return TESTING_END();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user