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

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

Issue 7590011: FTP: add directory listing parser for OS/2 format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_parser_unittest.h" 5 #include "net/ftp/ftp_directory_listing_parser_unittest.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 "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "net/ftp/ftp_directory_listing_parser_windows.h" 10 #include "net/ftp/ftp_directory_listing_parser_os2.h"
11 11
12 namespace net { 12 namespace net {
13 13
14 namespace { 14 namespace {
15 15
16 typedef FtpDirectoryListingParserTest FtpDirectoryListingParserWindowsTest; 16 typedef FtpDirectoryListingParserTest FtpDirectoryListingParserOS2Test;
17 17
18 TEST_F(FtpDirectoryListingParserWindowsTest, Good) { 18 TEST_F(FtpDirectoryListingParserOS2Test, Good) {
19 const struct SingleLineTestData good_cases[] = { 19 const struct SingleLineTestData good_cases[] = {
20 { "11-02-09 05:32PM <DIR> NT", 20 { "0 DIR 11-02-09 17:32 NT",
21 FtpDirectoryListingEntry::DIRECTORY, "NT", -1, 21 FtpDirectoryListingEntry::DIRECTORY, "NT", -1,
22 2009, 11, 2, 17, 32 }, 22 2009, 11, 2, 17, 32 },
23 { "01-06-09 02:42PM 458 Readme.txt", 23 { "458 A 01-06-09 14:42 Readme.txt",
24 FtpDirectoryListingEntry::FILE, "Readme.txt", 458, 24 FtpDirectoryListingEntry::FILE, "Readme.txt", 458,
25 2009, 1, 6, 14, 42 }, 25 2009, 1, 6, 14, 42 },
26 { "01-06-09 02:42AM 1 Readme.txt", 26 { "1 A 01-06-09 02:42 Readme.txt",
27 FtpDirectoryListingEntry::FILE, "Readme.txt", 1, 27 FtpDirectoryListingEntry::FILE, "Readme.txt", 1,
28 2009, 1, 6, 2, 42 }, 28 2009, 1, 6, 2, 42 },
29 { "01-06-01 02:42AM 458 Readme.txt", 29 { "458 A 01-06-01 02:42 Readme.txt",
30 FtpDirectoryListingEntry::FILE, "Readme.txt", 458, 30 FtpDirectoryListingEntry::FILE, "Readme.txt", 458,
31 2001, 1, 6, 2, 42 }, 31 2001, 1, 6, 2, 42 },
32 { "01-06-00 02:42AM 458 Corner1.txt", 32 { "458 A 01-06-00 02:42 Corner1.txt",
33 FtpDirectoryListingEntry::FILE, "Corner1.txt", 458, 33 FtpDirectoryListingEntry::FILE, "Corner1.txt", 458,
34 2000, 1, 6, 2, 42 }, 34 2000, 1, 6, 2, 42 },
35 { "01-06-99 02:42AM 458 Corner2.txt", 35 { "458 A 01-06-99 02:42 Corner2.txt",
36 FtpDirectoryListingEntry::FILE, "Corner2.txt", 458, 36 FtpDirectoryListingEntry::FILE, "Corner2.txt", 458,
37 1999, 1, 6, 2, 42 }, 37 1999, 1, 6, 2, 42 },
38 { "01-06-80 02:42AM 458 Corner3.txt", 38 { "458 A 01-06-80 02:42 Corner3.txt",
39 FtpDirectoryListingEntry::FILE, "Corner3.txt", 458, 39 FtpDirectoryListingEntry::FILE, "Corner3.txt", 458,
40 1980, 1, 6, 2, 42 }, 40 1980, 1, 6, 2, 42 },
41 #if !defined(OS_LINUX) 41 { "458 A 01-06-1979 02:42 Readme.txt",
42 // TODO(phajdan.jr): Re-enable when 2038-year problem is fixed on Linux.
43 { "01-06-79 02:42AM 458 Corner4",
44 FtpDirectoryListingEntry::FILE, "Corner4", 458,
45 2079, 1, 6, 2, 42 },
46 #endif // !defined (OS_LINUX)
47 { "01-06-1979 02:42AM 458 Readme.txt",
48 FtpDirectoryListingEntry::FILE, "Readme.txt", 458, 42 FtpDirectoryListingEntry::FILE, "Readme.txt", 458,
49 1979, 1, 6, 2, 42 }, 43 1979, 1, 6, 2, 42 },
50 { "11-02-09 05:32PM <DIR> My Directory", 44 { "0 DIR 11-02-09 17:32 My Directory",
51 FtpDirectoryListingEntry::DIRECTORY, "My Directory", -1, 45 FtpDirectoryListingEntry::DIRECTORY, "My Directory", -1,
52 2009, 11, 2, 17, 32 }, 46 2009, 11, 2, 17, 32 },
53 { "12-25-10 12:00AM <DIR> Christmas Midnight", 47 { "0 DIR 12-25-10 00:00 Christmas Midnight",
54 FtpDirectoryListingEntry::DIRECTORY, "Christmas Midnight", -1, 48 FtpDirectoryListingEntry::DIRECTORY, "Christmas Midnight", -1,
55 2010, 12, 25, 0, 0 }, 49 2010, 12, 25, 0, 0 },
56 { "12-25-10 12:00PM <DIR> Christmas Midday", 50 { "0 DIR 12-25-10 12:00 Christmas Midday",
57 FtpDirectoryListingEntry::DIRECTORY, "Christmas Midday", -1, 51 FtpDirectoryListingEntry::DIRECTORY, "Christmas Midday", -1,
58 2010, 12, 25, 12, 0 }, 52 2010, 12, 25, 12, 0 },
59 }; 53 };
60 for (size_t i = 0; i < arraysize(good_cases); i++) { 54 for (size_t i = 0; i < arraysize(good_cases); i++) {
61 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, 55 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
62 good_cases[i].input)); 56 good_cases[i].input));
63 57
64 std::vector<FtpDirectoryListingEntry> entries; 58 std::vector<FtpDirectoryListingEntry> entries;
65 EXPECT_TRUE(ParseFtpDirectoryListingWindows( 59 EXPECT_TRUE(ParseFtpDirectoryListingOS2(
66 GetSingleLineTestCase(good_cases[i].input), 60 GetSingleLineTestCase(good_cases[i].input),
67 &entries)); 61 &entries));
68 VerifySingleLineTestCase(good_cases[i], entries); 62 VerifySingleLineTestCase(good_cases[i], entries);
69 } 63 }
70 } 64 }
71 65
72 TEST_F(FtpDirectoryListingParserWindowsTest, Ignored) { 66 TEST_F(FtpDirectoryListingParserOS2Test, Ignored) {
73 const char* ignored_cases[] = { 67 const char* ignored_cases[] = {
74 "12-07-10 12:05AM <DIR> ", // http://crbug.com/66097 68 "1234 A 12-07-10 12:05",
75 "12-07-10 12:05AM 1234 ", 69 "0 DIR 11-02-09 05:32",
76 }; 70 };
77 for (size_t i = 0; i < arraysize(ignored_cases); i++) { 71 for (size_t i = 0; i < arraysize(ignored_cases); i++) {
78 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, 72 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
79 ignored_cases[i])); 73 ignored_cases[i]));
80 74
81 std::vector<FtpDirectoryListingEntry> entries; 75 std::vector<FtpDirectoryListingEntry> entries;
82 EXPECT_TRUE(ParseFtpDirectoryListingWindows( 76 EXPECT_TRUE(ParseFtpDirectoryListingOS2(
83 GetSingleLineTestCase(ignored_cases[i]), 77 GetSingleLineTestCase(ignored_cases[i]),
84 &entries)); 78 &entries));
85 EXPECT_EQ(0U, entries.size()); 79 EXPECT_EQ(0U, entries.size());
86 } 80 }
87 } 81 }
88 82
89 TEST_F(FtpDirectoryListingParserWindowsTest, Bad) { 83 TEST_F(FtpDirectoryListingParserOS2Test, Bad) {
90 const char* bad_cases[] = { 84 const char* bad_cases[] = {
91 "garbage", 85 "garbage",
92 "11-02-09 05:32PM <GARBAGE>", 86 "0 GARBAGE 11-02-09 05:32",
93 "11-02-09 05:32PM <GARBAGE> NT", 87 "0 GARBAGE 11-02-09 05:32 NT",
94 "11-02-09 05:32 <DIR>", 88 "0 DIR 11-FEB-09 05:32",
95 "11-FEB-09 05:32PM <DIR>", 89 "0 DIR 11-02 05:32",
96 "11-02 05:32PM <DIR>", 90 "-1 A 11-02-09 05:32",
97 "11-02-09 05:32PM -1", 91 "0 DIR 11-FEB-09 05:32",
98 "11-02-09 05:32 <DIR> NT", 92 "0 DIR 11-02 05:32 NT",
99 "11-FEB-09 05:32PM <DIR> NT", 93 "-1 A 11-02-09 05:32 NT",
100 "11-02 05:32PM <DIR> NT", 94 "0 A 99-25-10 12:00",
101 "11-02-09 05:32PM -1 NT", 95 "0 A 12-99-10 12:00",
102 "99-25-10 12:00AM 0", 96 "0 A 12-25-10 99:00",
103 "12-99-10 12:00AM 0", 97 "0 A 12-25-10 12:99",
104 "12-25-10 99:00AM 0", 98 "0 A 99-25-10 12:00 months out of range",
105 "12-25-10 12:99AM 0", 99 "0 A 12-99-10 12:00 days out of range",
106 "12-25-10 12:00ZM 0", 100 "0 A 12-25-10 99:00 hours out of range",
107 "99-25-10 12:00AM 0 months out of range", 101 "0 A 12-25-10 12:99 minutes out of range",
108 "12-99-10 12:00AM 0 days out of range",
109 "12-25-10 99:00AM 0 hours out of range",
110 "12-25-10 12:99AM 0 minutes out of range",
111 "12-25-10 12:00ZM 0 what does ZM mean",
112 }; 102 };
113 for (size_t i = 0; i < arraysize(bad_cases); i++) { 103 for (size_t i = 0; i < arraysize(bad_cases); i++) {
114 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, 104 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
115 bad_cases[i])); 105 bad_cases[i]));
116 106
117 std::vector<FtpDirectoryListingEntry> entries; 107 std::vector<FtpDirectoryListingEntry> entries;
118 EXPECT_FALSE(ParseFtpDirectoryListingWindows( 108 EXPECT_FALSE(ParseFtpDirectoryListingOS2(
119 GetSingleLineTestCase(bad_cases[i]), 109 GetSingleLineTestCase(bad_cases[i]),
120 &entries)); 110 &entries));
121 } 111 }
122 } 112 }
123 113
124 } // namespace 114 } // namespace
125 115
126 } // namespace net 116 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_os2.cc ('k') | net/ftp/ftp_directory_listing_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698