Handle quantifiers in parse_term()
This commit is contained in:
@@ -172,6 +172,45 @@ static void a_in_parens_b_is_parsed_as_sequence_with_regex_term(void)
|
||||
regex_free_children(&r);
|
||||
}
|
||||
|
||||
static void dot_star_is_parsed_as_zero_or_more_wildcard(void)
|
||||
{
|
||||
regex_t r = { 0 };
|
||||
const int result = PARSE_REGEX_STRING(".*", &r);
|
||||
ASSERT_NE(-1, result);
|
||||
|
||||
ASSERT_EQ(1, r.sequence.len);
|
||||
ASSERT_EQ(QUANTIFIER_ZERO_OR_MORE, r.sequence.contents[0].quantifier);
|
||||
ASSERT_EQ(TERM_TYPE_WILDCARD, r.sequence.contents[0].type);
|
||||
|
||||
regex_free_children(&r);
|
||||
}
|
||||
|
||||
static void dot_plus_is_parsed_as_one_or_more_wildcard(void)
|
||||
{
|
||||
regex_t r = { 0 };
|
||||
const int result = PARSE_REGEX_STRING(".+", &r);
|
||||
ASSERT_NE(-1, result);
|
||||
|
||||
ASSERT_EQ(1, r.sequence.len);
|
||||
ASSERT_EQ(QUANTIFIER_ONE_OR_MORE, r.sequence.contents[0].quantifier);
|
||||
ASSERT_EQ(TERM_TYPE_WILDCARD, r.sequence.contents[0].type);
|
||||
|
||||
regex_free_children(&r);
|
||||
}
|
||||
|
||||
static void dot_question_mark_is_parsed_as_zero_or_one_wildcard(void)
|
||||
{
|
||||
regex_t r = { 0 };
|
||||
const int result = PARSE_REGEX_STRING(".?", &r);
|
||||
ASSERT_NE(-1, result);
|
||||
|
||||
ASSERT_EQ(1, r.sequence.len);
|
||||
ASSERT_EQ(QUANTIFIER_ZERO_OR_ONE, r.sequence.contents[0].quantifier);
|
||||
ASSERT_EQ(TERM_TYPE_WILDCARD, r.sequence.contents[0].type);
|
||||
|
||||
regex_free_children(&r);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
TESTING_BEGIN();
|
||||
@@ -186,5 +225,8 @@ int main(void)
|
||||
backslash_backslash_is_parsed_as_unquantified_literal();
|
||||
a_pipe_b_in_parens_is_parsed_as_regex_term();
|
||||
a_in_parens_b_is_parsed_as_sequence_with_regex_term();
|
||||
dot_star_is_parsed_as_zero_or_more_wildcard();
|
||||
dot_plus_is_parsed_as_one_or_more_wildcard();
|
||||
dot_question_mark_is_parsed_as_zero_or_one_wildcard();
|
||||
return TESTING_END();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user