Implement special character escaping
This commit is contained in:
@@ -97,6 +97,34 @@ static void dot_is_parsed_as_unquantified_wildcard_term(void)
|
||||
regex_free_children(&r);
|
||||
}
|
||||
|
||||
static void backslash_dot_is_parsed_as_unquantified_literal(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_NONE, r.sequence.contents[0].quantifier);
|
||||
ASSERT_EQ(TERM_TYPE_LITERAL, r.sequence.contents[0].type);
|
||||
ASSERT_EQ('.', r.sequence.contents[0].literal);
|
||||
|
||||
regex_free_children(&r);
|
||||
}
|
||||
|
||||
static void backslash_backslash_is_parsed_as_unquantified_literal(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_NONE, r.sequence.contents[0].quantifier);
|
||||
ASSERT_EQ(TERM_TYPE_LITERAL, r.sequence.contents[0].type);
|
||||
ASSERT_EQ('\\', r.sequence.contents[0].literal);
|
||||
|
||||
regex_free_children(&r);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
TESTING_BEGIN();
|
||||
@@ -107,5 +135,7 @@ int main(void)
|
||||
b_is_parsed_as_unquantified_literal();
|
||||
abc_is_parsed_as_sequence_of_unquantified_literals();
|
||||
dot_is_parsed_as_unquantified_wildcard_term();
|
||||
backslash_dot_is_parsed_as_unquantified_literal();
|
||||
backslash_backslash_is_parsed_as_unquantified_literal();
|
||||
return TESTING_END();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user