diff options
Diffstat (limited to 'Tests/LibRegex')
-rw-r--r-- | Tests/LibRegex/RegexLibC.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Tests/LibRegex/RegexLibC.cpp b/Tests/LibRegex/RegexLibC.cpp index bea5e5984c..3df9837031 100644 --- a/Tests/LibRegex/RegexLibC.cpp +++ b/Tests/LibRegex/RegexLibC.cpp @@ -327,6 +327,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) pattern = b.build(); EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check); + regfree(®ex); // After vertical line b.clear(); @@ -335,6 +336,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) pattern = b.build(); EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check); + regfree(®ex); // After circumflex b.clear(); @@ -343,6 +345,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) pattern = b.build(); EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check); + regfree(®ex); // After dollar b.clear(); @@ -351,6 +354,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) pattern = b.build(); EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check); + regfree(®ex); // After left parens b.clear(); @@ -360,9 +364,8 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) pattern = b.build(); EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check); + regfree(®ex); } - - regfree(®ex); } TEST_CASE(parser_error_vertical_line_used_at_wrong_place) @@ -376,22 +379,24 @@ TEST_CASE(parser_error_vertical_line_used_at_wrong_place) pattern = "|asdf"; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_EMPTY_EXPR); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), REG_EMPTY_EXPR); + regfree(®ex); // Last in ere pattern = "asdf|"; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_EMPTY_EXPR); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), REG_EMPTY_EXPR); + regfree(®ex); // After left parens pattern = "(|asdf)"; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_EMPTY_EXPR); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), REG_EMPTY_EXPR); + regfree(®ex); // Proceed right parens pattern = "(asdf)|"; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_EMPTY_EXPR); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), REG_EMPTY_EXPR); - regfree(®ex); } @@ -969,6 +974,7 @@ TEST_CASE(simple_bracket_chars) EXPECT_EQ(regexec(®ex, "c", 0, NULL, 0), REG_NOERR); EXPECT_EQ(regexec(®ex, "d", 0, NULL, 0), REG_NOMATCH); EXPECT_EQ(regexec(®ex, "e", 0, NULL, 0), REG_NOMATCH); + regfree(®ex); } TEST_CASE(simple_bracket_chars_inverse) @@ -982,6 +988,7 @@ TEST_CASE(simple_bracket_chars_inverse) EXPECT_EQ(regexec(®ex, "c", 0, NULL, 0), REG_NOMATCH); EXPECT_EQ(regexec(®ex, "d", 0, NULL, 0), REG_NOERR); EXPECT_EQ(regexec(®ex, "e", 0, NULL, 0), REG_NOERR); + regfree(®ex); } TEST_CASE(simple_bracket_chars_range) @@ -995,6 +1002,7 @@ TEST_CASE(simple_bracket_chars_range) EXPECT_EQ(regexec(®ex, "c", 0, NULL, 0), REG_NOERR); EXPECT_EQ(regexec(®ex, "d", 0, NULL, 0), REG_NOERR); EXPECT_EQ(regexec(®ex, "e", 0, NULL, 0), REG_NOMATCH); + regfree(®ex); } TEST_CASE(simple_bracket_chars_range_inverse) @@ -1010,6 +1018,7 @@ TEST_CASE(simple_bracket_chars_range_inverse) EXPECT_EQ(regexec(®ex, "e", 0, NULL, 0), REG_NOERR); EXPECT_EQ(regexec(®ex, "k", 0, NULL, 0), REG_NOMATCH); EXPECT_EQ(regexec(®ex, "z", 0, NULL, 0), REG_NOMATCH); + regfree(®ex); } TEST_CASE(bracket_character_class_uuid) @@ -1035,6 +1044,7 @@ TEST_CASE(simple_bracket_character_class_inverse) EXPECT_EQ(regexec(®ex, "3", 0, NULL, 0), REG_NOMATCH); EXPECT_EQ(regexec(®ex, "d", 0, NULL, 0), REG_NOERR); EXPECT_EQ(regexec(®ex, "e", 0, NULL, 0), REG_NOERR); + regfree(®ex); } TEST_CASE(email_address) @@ -1115,4 +1125,5 @@ TEST_CASE(simple_notbol_noteol) EXPECT_EQ(regexec(®ex2, "hello friends", 0, NULL, REG_NOTEOL), REG_NOMATCH); regfree(®ex); + regfree(®ex2); } |