| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "net/base/escape.h" | 7 #include "net/base/escape.h" |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 // When we're not unescaping NULLs. | 153 // When we're not unescaping NULLs. |
| 154 expected = "Null"; | 154 expected = "Null"; |
| 155 expected.push_back(0); | 155 expected.push_back(0); |
| 156 expected.append("%009Test"); | 156 expected.append("%009Test"); |
| 157 EXPECT_EQ(expected, UnescapeURLComponent(input, UnescapeRule::NORMAL)); | 157 EXPECT_EQ(expected, UnescapeURLComponent(input, UnescapeRule::NORMAL)); |
| 158 } | 158 } |
| 159 | 159 |
| 160 TEST(Escape, UnescapeAndDecodeURLComponent) { | 160 TEST(Escape, UnescapeAndDecodeURLComponent) { |
| 161 const UnescapeAndDecodeURLCase unescape_cases[] = { | 161 const UnescapeAndDecodeURLCase unescape_cases[] = { |
| 162 {"UTF8", "%", "%", "%", L"%"}, |
| 162 {"UTF8", "+", "+", " ", L"+"}, | 163 {"UTF8", "+", "+", " ", L"+"}, |
| 163 {"UTF8", "%2+", "%2+", "%2 ", L"%2+"}, | 164 {"UTF8", "%2+", "%2+", "%2 ", L"%2+"}, |
| 164 {"UTF8", "+%%%+%%%", "+%%%+%%%", " %%% %%%", L"+%%%+%%%"}, | 165 {"UTF8", "+%%%+%%%", "+%%%+%%%", " %%% %%%", L"+%%%+%%%"}, |
| 165 {"UTF8", "Don't escape anything", | 166 {"UTF8", "Don't escape anything", |
| 166 "Don't escape anything", | 167 "Don't escape anything", |
| 167 "Don't escape anything", | 168 "Don't escape anything", |
| 168 L"Don't escape anything"}, | 169 L"Don't escape anything"}, |
| 169 {"UTF8", "+Invalid %escape %2+", | 170 {"UTF8", "+Invalid %escape %2+", |
| 170 "+Invalid %escape %2+", | 171 "+Invalid %escape %2+", |
| 171 " Invalid %escape %2 ", | 172 " Invalid %escape %2 ", |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 { "<hello>", "<hello>" }, | 216 { "<hello>", "<hello>" }, |
| 216 { "don\'t mess with me", "don't mess with me" }, | 217 { "don\'t mess with me", "don't mess with me" }, |
| 217 }; | 218 }; |
| 218 for (size_t i = 0; i < arraysize(tests); ++i) { | 219 for (size_t i = 0; i < arraysize(tests); ++i) { |
| 219 std::string result = EscapeForHTML(std::string(tests[i].input)); | 220 std::string result = EscapeForHTML(std::string(tests[i].input)); |
| 220 EXPECT_EQ(std::string(tests[i].expected_output), result); | 221 EXPECT_EQ(std::string(tests[i].expected_output), result); |
| 221 } | 222 } |
| 222 } | 223 } |
| 223 | 224 |
| 224 | 225 |
| OLD | NEW |