Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: net/base/url_util_unittest.cc

Issue 632843003: Add a function to escape a query part of url (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename the function to EscapeQueryParameters Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« net/base/url_util.h ('K') | « net/base/url_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/url_util.h" 5 #include "net/base/url_util.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "url/gurl.h" 8 #include "url/gurl.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 EXPECT_TRUE(it.IsAtEnd()); 153 EXPECT_TRUE(it.IsAtEnd());
154 } 154 }
155 155
156 TEST(UrlUtilTest, ParseQueryInvalidURL) { 156 TEST(UrlUtilTest, ParseQueryInvalidURL) {
157 const GURL url("http://%01/?test"); 157 const GURL url("http://%01/?test");
158 QueryIterator it(url); 158 QueryIterator it(url);
159 EXPECT_TRUE(it.IsAtEnd()); 159 EXPECT_TRUE(it.IsAtEnd());
160 } 160 }
161 161
162 TEST(UrlUtilTest, EscapeQueryPart) {
163 EXPECT_EQ("http://example.com/test?q=a%7Cb%7Cc",
164 EscapeQueryParameters(GURL("http://example.com/test?q=a%7Cb%7Cc"))
165 .spec());
166
167 EXPECT_EQ(
168 "http://example.com/test?q=a%7Cb%7Cc",
169 EscapeQueryParameters(GURL("http://example.com/test?q=a|b|c")).spec());
170
171 EXPECT_EQ("http://example.com/test?q=a%7Cb%7Cc&q=1%7C2%7C3",
172 EscapeQueryParameters(
173 GURL("http://example.com/test?q=a|b|c&q=1|2|3")).spec());
174
175 EXPECT_EQ("http://example.com/test?q=a%7Cb%7Cc&q2=1%7C2%7C3",
176 EscapeQueryParameters(
177 GURL("http://example.com/test?q=a|b|c&q2=1|2|3")).spec());
178
179 EXPECT_EQ("http://example.com/",
180 EscapeQueryParameters(GURL("http://example.com/")).spec());
181 }
182
162 } // namespace 183 } // namespace
163 } // namespace net 184 } // namespace net
OLDNEW
« net/base/url_util.h ('K') | « net/base/url_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698