| Index: net/base/url_util_unittest.cc
|
| diff --git a/net/base/url_util_unittest.cc b/net/base/url_util_unittest.cc
|
| index 158e2740306e29bcdcfd1ab53b6d5cfcbd39af43..b150536cfa6f0195fcacd91ff1ba2335e98ff588 100644
|
| --- a/net/base/url_util_unittest.cc
|
| +++ b/net/base/url_util_unittest.cc
|
| @@ -13,77 +13,86 @@ namespace {
|
| TEST(UrlUtilTest, AppendQueryParameter) {
|
| // Appending a name-value pair to a URL without a query component.
|
| EXPECT_EQ("http://example.com/path?name=value",
|
| - AppendQueryParameter(GURL("http://example.com/path"),
|
| - "name", "value").spec());
|
| + AppendQueryParameter(
|
| + GURL("http://example.com/path"), "name", "value").spec());
|
|
|
| // Appending a name-value pair to a URL with a query component.
|
| // The original component should be preserved, and the new pair should be
|
| // appended with '&'.
|
| EXPECT_EQ("http://example.com/path?existing=one&name=value",
|
| AppendQueryParameter(GURL("http://example.com/path?existing=one"),
|
| - "name", "value").spec());
|
| + "name",
|
| + "value").spec());
|
|
|
| // Appending a name-value pair with unsafe characters included. The
|
| // unsafe characters should be escaped.
|
| EXPECT_EQ("http://example.com/path?existing=one&na+me=v.alue%3D",
|
| AppendQueryParameter(GURL("http://example.com/path?existing=one"),
|
| - "na me", "v.alue=").spec());
|
| -
|
| + "na me",
|
| + "v.alue=").spec());
|
| }
|
|
|
| TEST(UrlUtilTest, AppendOrReplaceQueryParameter) {
|
| // Appending a name-value pair to a URL without a query component.
|
| EXPECT_EQ("http://example.com/path?name=value",
|
| - AppendOrReplaceQueryParameter(GURL("http://example.com/path"),
|
| - "name", "value").spec());
|
| + AppendOrReplaceQueryParameter(
|
| + GURL("http://example.com/path"), "name", "value").spec());
|
|
|
| // Appending a name-value pair to a URL with a query component.
|
| // The original component should be preserved, and the new pair should be
|
| // appended with '&'.
|
| EXPECT_EQ("http://example.com/path?existing=one&name=value",
|
| - AppendOrReplaceQueryParameter(
|
| - GURL("http://example.com/path?existing=one"),
|
| - "name", "value").spec());
|
| + AppendOrReplaceQueryParameter(
|
| + GURL("http://example.com/path?existing=one"), "name", "value")
|
| + .spec());
|
|
|
| // Appending a name-value pair with unsafe characters included. The
|
| // unsafe characters should be escaped.
|
| - EXPECT_EQ("http://example.com/path?existing=one&na+me=v.alue%3D",
|
| + EXPECT_EQ(
|
| + "http://example.com/path?existing=one&na+me=v.alue%3D",
|
| AppendOrReplaceQueryParameter(
|
| - GURL("http://example.com/path?existing=one"),
|
| - "na me", "v.alue=").spec());
|
| + GURL("http://example.com/path?existing=one"), "na me", "v.alue=")
|
| + .spec());
|
|
|
| // Replace value of an existing paramater.
|
| - EXPECT_EQ("http://example.com/path?existing=one&name=new",
|
| + EXPECT_EQ(
|
| + "http://example.com/path?existing=one&name=new",
|
| AppendOrReplaceQueryParameter(
|
| - GURL("http://example.com/path?existing=one&name=old"),
|
| - "name", "new").spec());
|
| + GURL("http://example.com/path?existing=one&name=old"), "name", "new")
|
| + .spec());
|
|
|
| // Replace a name-value pair with unsafe characters included. The
|
| // unsafe characters should be escaped.
|
| EXPECT_EQ("http://example.com/path?na+me=n.ew%3D&existing=one",
|
| - AppendOrReplaceQueryParameter(
|
| - GURL("http://example.com/path?na+me=old&existing=one"),
|
| - "na me", "n.ew=").spec());
|
| + AppendOrReplaceQueryParameter(
|
| + GURL("http://example.com/path?na+me=old&existing=one"),
|
| + "na me",
|
| + "n.ew=").spec());
|
|
|
| // Replace the value of first parameter with this name only.
|
| EXPECT_EQ("http://example.com/path?name=new&existing=one&name=old",
|
| - AppendOrReplaceQueryParameter(
|
| - GURL("http://example.com/path?name=old&existing=one&name=old"),
|
| - "name", "new").spec());
|
| + AppendOrReplaceQueryParameter(
|
| + GURL("http://example.com/path?name=old&existing=one&name=old"),
|
| + "name",
|
| + "new").spec());
|
|
|
| // Preserve the content of the original params regarless of our failure to
|
| // interpret them correctly.
|
| - EXPECT_EQ("http://example.com/path?bar&name=new&left=&"
|
| - "=right&=&&name=again",
|
| + EXPECT_EQ(
|
| + "http://example.com/path?bar&name=new&left=&"
|
| + "=right&=&&name=again",
|
| AppendOrReplaceQueryParameter(
|
| - GURL("http://example.com/path?bar&name=old&left=&"
|
| - "=right&=&&name=again"),
|
| - "name", "new").spec());
|
| + GURL(
|
| + "http://example.com/path?bar&name=old&left=&"
|
| + "=right&=&&name=again"),
|
| + "name",
|
| + "new").spec());
|
| }
|
|
|
| TEST(UrlUtilTest, GetValueForKeyInQuery) {
|
| - GURL url("http://example.com/path?name=value&boolParam&"
|
| - "url=http://test.com/q?n1%3Dv1%26n2");
|
| + GURL url(
|
| + "http://example.com/path?name=value&boolParam&"
|
| + "url=http://test.com/q?n1%3Dv1%26n2");
|
| std::string value;
|
|
|
| // False when getting a non-existent query param.
|
| @@ -109,9 +118,10 @@ TEST(UrlUtilTest, GetValueForKeyInQueryInvalidURL) {
|
| }
|
|
|
| TEST(UrlUtilTest, ParseQuery) {
|
| - const GURL url("http://example.com/path?name=value&boolParam&"
|
| - "url=http://test.com/q?n1%3Dv1%26n2&"
|
| - "multikey=value1&multikey=value2&multikey");
|
| + const GURL url(
|
| + "http://example.com/path?name=value&boolParam&"
|
| + "url=http://test.com/q?n1%3Dv1%26n2&"
|
| + "multikey=value1&multikey=value2&multikey");
|
| QueryIterator it(url);
|
|
|
| ASSERT_FALSE(it.IsAtEnd());
|
|
|