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

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

Issue 23619016: Switch the offset conversion routines from... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 330
331 // TODO: Need to test unescape_spaces and unescape_percent. 331 // TODO: Need to test unescape_spaces and unescape_percent.
332 base::string16 decoded = UnescapeAndDecodeUTF8URLComponent( 332 base::string16 decoded = UnescapeAndDecodeUTF8URLComponent(
333 unescape_cases[i].input, UnescapeRule::NORMAL, NULL); 333 unescape_cases[i].input, UnescapeRule::NORMAL, NULL);
334 EXPECT_EQ(WideToUTF16(unescape_cases[i].decoded), decoded); 334 EXPECT_EQ(WideToUTF16(unescape_cases[i].decoded), decoded);
335 } 335 }
336 } 336 }
337 337
338 TEST(EscapeTest, AdjustOffset) { 338 TEST(EscapeTest, AdjustOffset) {
339 const AdjustOffsetCase adjust_cases[] = { 339 const AdjustOffsetCase adjust_cases[] = {
340 {"", 0, std::string::npos}, 340 {"", 0, 0},
341 {"", 1, std::string::npos},
341 {"test", 0, 0}, 342 {"test", 0, 0},
342 {"test", 2, 2}, 343 {"test", 2, 2},
343 {"test", 4, std::string::npos}, 344 {"test", 4, 4},
345 {"test", 5, std::string::npos},
344 {"test", std::string::npos, std::string::npos}, 346 {"test", std::string::npos, std::string::npos},
345 {"%2dtest", 6, 4}, 347 {"%2dtest", 6, 4},
346 {"%2dtest", 2, std::string::npos}, 348 {"%2dtest", 2, std::string::npos},
347 {"test%2d", 2, 2}, 349 {"test%2d", 2, 2},
348 {"%E4%BD%A0+%E5%A5%BD", 9, 1}, 350 {"%E4%BD%A0+%E5%A5%BD", 9, 1},
349 {"%E4%BD%A0+%E5%A5%BD", 6, std::string::npos}, 351 {"%E4%BD%A0+%E5%A5%BD", 6, std::string::npos},
350 {"%ED%B0%80+%E5%A5%BD", 6, 6}, 352 {"%ED%B0%80+%E5%A5%BD", 6, 6},
351 }; 353 };
352 354
353 for (size_t i = 0; i < arraysize(adjust_cases); i++) { 355 for (size_t i = 0; i < arraysize(adjust_cases); i++) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 internal::AdjustEncodingOffset(adjustments)); 423 internal::AdjustEncodingOffset(adjustments));
422 size_t expected_2[] = {0, kNpos, kNpos, 1, 2, 3, 4, kNpos, kNpos, 5, kNpos, 424 size_t expected_2[] = {0, kNpos, kNpos, 1, 2, 3, 4, kNpos, kNpos, 5, kNpos,
423 kNpos, 6, 7, 8, 9, kNpos, kNpos}; 425 kNpos, 6, 7, 8, 9, kNpos, kNpos};
424 EXPECT_EQ(offsets.size(), arraysize(expected_2)); 426 EXPECT_EQ(offsets.size(), arraysize(expected_2));
425 for (size_t i = 0; i < arraysize(expected_2); ++i) 427 for (size_t i = 0; i < arraysize(expected_2); ++i)
426 EXPECT_EQ(expected_2[i], offsets[i]); 428 EXPECT_EQ(expected_2[i], offsets[i]);
427 } 429 }
428 430
429 } // namespace 431 } // namespace
430 } // namespace net 432 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698