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

Side by Side Diff: net/ftp/ftp_directory_listing_parsers_unittest.cc

Issue 449011: Make new FTP LIST parsing code more robust. (Closed)
Patch Set: fixes Created 11 years 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/ftp/ftp_directory_listing_parsers.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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/ftp/ftp_directory_listing_parsers.h" 5 #include "net/ftp/ftp_directory_listing_parsers.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 now_exploded.year, 5, 15, 18, 11 }, 64 now_exploded.year, 5, 15, 18, 11 },
65 { "lrwxrwxrwx 1 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub", 65 { "lrwxrwxrwx 1 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub",
66 net::FtpDirectoryListingEntry::SYMLINK, "pub", -1, 66 net::FtpDirectoryListingEntry::SYMLINK, "pub", -1,
67 2008, 9, 18, 0, 0 }, 67 2008, 9, 18, 0, 0 },
68 { "lrwxrwxrwx 1 0 0 3 Oct 12 13:37 mirror -> pub", 68 { "lrwxrwxrwx 1 0 0 3 Oct 12 13:37 mirror -> pub",
69 net::FtpDirectoryListingEntry::SYMLINK, "mirror", -1, 69 net::FtpDirectoryListingEntry::SYMLINK, "mirror", -1,
70 now_exploded.year, 10, 12, 13, 37 }, 70 now_exploded.year, 10, 12, 13, 37 },
71 { "drwxrwsr-x 4 501 501 4096 Feb 20 2007 pub", 71 { "drwxrwsr-x 4 501 501 4096 Feb 20 2007 pub",
72 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, 72 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1,
73 2007, 2, 20, 0, 0 }, 73 2007, 2, 20, 0, 0 },
74 { "drwxr-xr-x 4 (?) (?) 4096 Apr 8 2007 jigdo",
75 net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1,
76 2007, 4, 8, 0, 0 },
77 { "drwx-wx-wt 2 root wheel 512 Jul 1 02:15 incoming",
78 net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1,
79 now_exploded.year, 7, 1, 2, 15 },
80 { "-rw-r--r-- 1 2 3 3447432 May 18 2009 Foo - Manual.pdf",
81 net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432,
82 2009, 5, 18, 0, 0 },
74 }; 83 };
75 for (size_t i = 0; i < arraysize(good_cases); i++) { 84 for (size_t i = 0; i < arraysize(good_cases); i++) {
76 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); 85 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input));
77 86
78 net::FtpLsDirectoryListingParser parser; 87 net::FtpLsDirectoryListingParser parser;
79 RunSingleLineTestCase(&parser, good_cases[i]); 88 RunSingleLineTestCase(&parser, good_cases[i]);
80 } 89 }
81 90
82 const char* bad_cases[] = { 91 const char* bad_cases[] = {
83 "garbage", 92 "garbage",
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 if (!parser.ConsumeLine(UTF8ToUTF16(*i))) { 258 if (!parser.ConsumeLine(UTF8ToUTF16(*i))) {
250 failed = true; 259 failed = true;
251 break; 260 break;
252 } 261 }
253 } 262 }
254 EXPECT_TRUE(failed); 263 EXPECT_TRUE(failed);
255 } 264 }
256 } 265 }
257 266
258 } // namespace 267 } // namespace
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parsers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698