Merge pull request #186 from peter50216/master

C++ IdentifierUtils::RemoveIdentifierFreeText behaves incorrectly.
This commit is contained in:
Val Markovic 2013-03-23 10:55:13 -07:00
commit bd75efedbc
2 changed files with 20 additions and 2 deletions

View File

@ -31,10 +31,10 @@ const char *COMMENT_AND_STRING_REGEX =
"/\\*.*?\\*/" // C-style comments, '/* ... */'
"|"
// Anything inside single quotes, '...', but mind the escaped quote
"'(?:\\\\'|.)*?'"
"'(?:\\\\\\\\|\\\\'|.)*?'"
"|"
// Anything inside double quotes, "...", but mind the escaped double quote
"\"(?:\\\\\"|.)*?\"";
"\"(?:\\\\\\\\|\\\\\"|.)*?\"";
const char *IDENTIFIER_REGEX = "[_a-zA-Z]\\w*";

View File

@ -89,6 +89,24 @@ TEST( IdentifierUtilsTest, RemoveIdentifierFreeTextWorks ) {
"foo \n"
"bar \n"
"qux" );
EXPECT_STREQ( RemoveIdentifierFreeText(
"foo \n"
"bar \"fo\\\\\"baz\n"
"qux \"qwe\""
).c_str(),
"foo \n"
"bar baz\n"
"qux " );
EXPECT_STREQ( RemoveIdentifierFreeText(
"foo '\\\\'\n"
"bar '\\\\'\n"
"qux '\\\\'"
).c_str(),
"foo \n"
"bar \n"
"qux " );
}