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

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

Issue 465035: Split FTP LIST parsing code into individual files for each listing style. (Closed)
Patch Set: fix 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/ftp/ftp_directory_listing_parser_unittest.h"
6
7 #include "base/format_macros.h"
8 #include "net/ftp/ftp_directory_listing_parser_ls.h"
9
10 namespace {
11
12 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserLsTest;
13
14 TEST_F(FtpDirectoryListingParserLsTest, Good) {
15 base::Time::Exploded now_exploded;
16 base::Time::Now().LocalExplode(&now_exploded);
17
18 const struct SingleLineTestData good_cases[] = {
19 { "-rw-r--r-- 1 ftp ftp 528 Nov 01 2007 README",
20 net::FtpDirectoryListingEntry::FILE, "README", 528,
21 2007, 11, 1, 0, 0 },
22 { "drwxr-xr-x 3 ftp ftp 4096 May 15 18:11 directory",
23 net::FtpDirectoryListingEntry::DIRECTORY, "directory", -1,
24 now_exploded.year, 5, 15, 18, 11 },
25 { "lrwxrwxrwx 1 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub",
26 net::FtpDirectoryListingEntry::SYMLINK, "pub", -1,
27 2008, 9, 18, 0, 0 },
28 { "lrwxrwxrwx 1 0 0 3 Oct 12 13:37 mirror -> pub",
29 net::FtpDirectoryListingEntry::SYMLINK, "mirror", -1,
30 now_exploded.year, 10, 12, 13, 37 },
31 { "drwxrwsr-x 4 501 501 4096 Feb 20 2007 pub",
32 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1,
33 2007, 2, 20, 0, 0 },
34 { "drwxr-xr-x 4 (?) (?) 4096 Apr 8 2007 jigdo",
35 net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1,
36 2007, 4, 8, 0, 0 },
37 { "drwx-wx-wt 2 root wheel 512 Jul 1 02:15 incoming",
38 net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1,
39 now_exploded.year, 7, 1, 2, 15 },
40 { "-rw-r--r-- 1 2 3 3447432 May 18 2009 Foo - Manual.pdf",
41 net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432,
42 2009, 5, 18, 0, 0 },
43 };
44 for (size_t i = 0; i < arraysize(good_cases); i++) {
45 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input));
46
47 net::FtpDirectoryListingParserLs parser;
48 RunSingleLineTestCase(&parser, good_cases[i]);
49 }
50 }
51
52 TEST_F(FtpDirectoryListingParserLsTest, Bad) {
53 const char* bad_cases[] = {
54 "garbage",
55 "-rw-r--r-- 1 ftp ftp",
56 "-rw-r--rgb 1 ftp ftp 528 Nov 01 2007 README",
57 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README",
58 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README",
59 "-rw-r--r-- -1 ftp ftp 528 Nov 01 2007 README",
60 "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README",
61 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README",
62 };
63 for (size_t i = 0; i < arraysize(bad_cases); i++) {
64 net::FtpDirectoryListingParserLs parser;
65 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i];
66 }
67 }
68
69 } // namespace
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_ls.cc ('k') | net/ftp/ftp_directory_listing_parser_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698