| Index: chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
|
| diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
|
| index 1f36d717779e5b33c305a626cac266f45e35fec2..ed0912761332530efe8bada583a83161f8d4e33b 100644
|
| --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
|
| +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
|
| @@ -100,4 +100,32 @@ TEST(WebRequestActionTest, CreateActionSet) {
|
| EXPECT_FALSE(result.get());
|
| }
|
|
|
| +// Test capture group syntax conversions of WebRequestRedirectByRegExAction
|
| +TEST(WebRequestActionTest, PerlToRe2Style) {
|
| +#define CallPerlToRe2Style WebRequestRedirectByRegExAction::PerlToRe2Style
|
| + // foo$1bar -> foo\1bar
|
| + EXPECT_EQ("foo\\1bar", CallPerlToRe2Style("foo$1bar"));
|
| + // foo\$1bar -> foo$1bar
|
| + EXPECT_EQ("foo$1bar", CallPerlToRe2Style("foo\\$1bar"));
|
| + // foo\\$1bar -> foo\\\1bar
|
| + EXPECT_EQ("foo\\\\\\1bar", CallPerlToRe2Style("foo\\\\$1bar"));
|
| + // foo\bar -> foobar
|
| + EXPECT_EQ("foobar", CallPerlToRe2Style("foo\\bar"));
|
| + // foo$bar -> foo$bar
|
| + EXPECT_EQ("foo$bar", CallPerlToRe2Style("foo$bar"));
|
| +#undef CallPerlToRe2Style
|
| +}
|
| +
|
| +// Test capture group syntax conversions of WebRequestRedirectByRegExAction
|
| +TEST(WebRequestActionTest, Re2ToPerlStyle) {
|
| +#define CallRe2ToPerlStyle WebRequestRedirectByRegExAction::Re2ToPerlStyle
|
| + // foo\1bar -> foo$1bar
|
| + EXPECT_EQ("foo$1bar", CallRe2ToPerlStyle("foo\\1bar"));
|
| + // foo\\1bar -> foo\\1bar
|
| + EXPECT_EQ("foo\\\\1bar", CallRe2ToPerlStyle("foo\\\\1bar"));
|
| + // foo\\\1bar -> foo\\$1bar
|
| + EXPECT_EQ("foo\\\\$1bar", CallRe2ToPerlStyle("foo\\\\\\1bar"));
|
| +#undef CallRe2ToPerlStyle
|
| +}
|
| +
|
| } // namespace extensions
|
|
|