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

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

Issue 681713002: Update from chromium https://crrev.com/301315 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « net/base/escape.cc ('k') | net/base/net_log_logger.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 7
8 #include "net/base/escape.h" 8 #include "net/base/escape.h"
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 { "&lt;", "<" }, 472 { "&lt;", "<" },
473 { "&gt;", ">" }, 473 { "&gt;", ">" },
474 { "&amp; &", "& &" }, 474 { "&amp; &", "& &" },
475 }; 475 };
476 for (size_t i = 0; i < arraysize(tests); ++i) { 476 for (size_t i = 0; i < arraysize(tests); ++i) {
477 base::string16 result = UnescapeForHTML(base::ASCIIToUTF16(tests[i].input)); 477 base::string16 result = UnescapeForHTML(base::ASCIIToUTF16(tests[i].input));
478 EXPECT_EQ(base::ASCIIToUTF16(tests[i].expected_output), result); 478 EXPECT_EQ(base::ASCIIToUTF16(tests[i].expected_output), result);
479 } 479 }
480 } 480 }
481 481
482 TEST(EscapeTest, EscapeExternalHandlerValue) {
483 ASSERT_EQ(
484 // Escaped
485 "%02%0A%1D%20!%22#$%25&'()*+,-./0123456789:;"
486 "%3C=%3E?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
487 "[%5C]%5E_%60abcdefghijklmnopqrstuvwxyz"
488 "%7B%7C%7D~%7F%80%FF",
489 // Most of the character space we care about, un-escaped
490 EscapeExternalHandlerValue(
491 "\x02\n\x1d !\"#$%&'()*+,-./0123456789:;"
492 "<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
493 "[\\]^_`abcdefghijklmnopqrstuvwxyz"
494 "{|}~\x7f\x80\xff"));
495
496 ASSERT_EQ(
497 "!#$&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]_"
498 "abcdefghijklmnopqrstuvwxyz~",
499 EscapeExternalHandlerValue(
500 "!#$&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]_"
501 "abcdefghijklmnopqrstuvwxyz~"));
502
503 ASSERT_EQ("%258k", EscapeExternalHandlerValue("%8k"));
504 ASSERT_EQ("a%25", EscapeExternalHandlerValue("a%"));
505 ASSERT_EQ("%25a", EscapeExternalHandlerValue("%a"));
506 ASSERT_EQ("a%258", EscapeExternalHandlerValue("a%8"));
507 ASSERT_EQ("%ab", EscapeExternalHandlerValue("%ab"));
508 ASSERT_EQ("%AB", EscapeExternalHandlerValue("%AB"));
509
510 ASSERT_EQ("http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C",
511 EscapeExternalHandlerValue(
512 "http://example.com/path/sub?q=a|b|c&q=1|2|3#ref|"));
513 ASSERT_EQ("http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C",
514 EscapeExternalHandlerValue(
515 "http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C"));
516 ASSERT_EQ("http://[2001:db8:0:1]:80",
517 EscapeExternalHandlerValue("http://[2001:db8:0:1]:80"));
518 }
482 519
483 } // namespace 520 } // namespace
484 } // namespace net 521 } // namespace net
OLDNEW
« no previous file with comments | « net/base/escape.cc ('k') | net/base/net_log_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698