Merge pull request #186 from peter50216/master
C++ IdentifierUtils::RemoveIdentifierFreeText behaves incorrectly.
This commit is contained in:
commit
bd75efedbc
@ -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*";
|
||||
|
||||
|
@ -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 " );
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user