Remove wallet integration from requestAutocomplete, desktop, step 1: UI
[chromium-blink-merge.git] / net / ftp / ftp_directory_listing_parser_windows_unittest.cc
blob1c6234ec36c9186c193b6d9b3f31f72d35f11be6
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
3 // found in the LICENSE file.
5 #include "net/ftp/ftp_directory_listing_parser_unittest.h"
7 #include "base/format_macros.h"
8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h"
10 #include "net/ftp/ftp_directory_listing_parser_windows.h"
12 namespace net {
14 namespace {
16 typedef FtpDirectoryListingParserTest FtpDirectoryListingParserWindowsTest;
18 TEST_F(FtpDirectoryListingParserWindowsTest, Good) {
19 const struct SingleLineTestData good_cases[] = {
20 { "11-02-09 05:32PM <DIR> NT",
21 FtpDirectoryListingEntry::DIRECTORY, "NT", -1,
22 2009, 11, 2, 17, 32 },
23 { "01-06-09 02:42PM 458 Readme.txt",
24 FtpDirectoryListingEntry::FILE, "Readme.txt", 458,
25 2009, 1, 6, 14, 42 },
26 { "01-06-09 02:42AM 1 Readme.txt",
27 FtpDirectoryListingEntry::FILE, "Readme.txt", 1,
28 2009, 1, 6, 2, 42 },
29 { "01-06-01 02:42AM 458 Readme.txt",
30 FtpDirectoryListingEntry::FILE, "Readme.txt", 458,
31 2001, 1, 6, 2, 42 },
32 { "01-06-00 02:42AM 458 Corner1.txt",
33 FtpDirectoryListingEntry::FILE, "Corner1.txt", 458,
34 2000, 1, 6, 2, 42 },
35 { "01-06-99 02:42AM 458 Corner2.txt",
36 FtpDirectoryListingEntry::FILE, "Corner2.txt", 458,
37 1999, 1, 6, 2, 42 },
38 { "01-06-80 02:42AM 458 Corner3.txt",
39 FtpDirectoryListingEntry::FILE, "Corner3.txt", 458,
40 1980, 1, 6, 2, 42 },
41 #if !defined(OS_LINUX) && !defined(OS_ANDROID)
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) && !defined(OS_ANDROID)
47 { "01-06-1979 02:42AM 458 Readme.txt",
48 FtpDirectoryListingEntry::FILE, "Readme.txt", 458,
49 1979, 1, 6, 2, 42 },
50 { "11-02-09 05:32PM <DIR> My Directory",
51 FtpDirectoryListingEntry::DIRECTORY, "My Directory", -1,
52 2009, 11, 2, 17, 32 },
53 { "12-25-10 12:00AM <DIR> Christmas Midnight",
54 FtpDirectoryListingEntry::DIRECTORY, "Christmas Midnight", -1,
55 2010, 12, 25, 0, 0 },
56 { "12-25-10 12:00PM <DIR> Christmas Midday",
57 FtpDirectoryListingEntry::DIRECTORY, "Christmas Midday", -1,
58 2010, 12, 25, 12, 0 },
60 for (size_t i = 0; i < arraysize(good_cases); i++) {
61 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
62 good_cases[i].input));
64 std::vector<FtpDirectoryListingEntry> entries;
65 EXPECT_TRUE(ParseFtpDirectoryListingWindows(
66 GetSingleLineTestCase(good_cases[i].input),
67 &entries));
68 VerifySingleLineTestCase(good_cases[i], entries);
72 TEST_F(FtpDirectoryListingParserWindowsTest, Ignored) {
73 const char* const ignored_cases[] = {
74 "12-07-10 12:05AM <DIR> ", // http://crbug.com/66097
75 "12-07-10 12:05AM 1234 ",
76 "11-02-09 05:32 <DIR>",
77 "11-02-09 05:32PM <DIR>",
79 for (size_t i = 0; i < arraysize(ignored_cases); i++) {
80 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
81 ignored_cases[i]));
83 std::vector<FtpDirectoryListingEntry> entries;
84 EXPECT_TRUE(ParseFtpDirectoryListingWindows(
85 GetSingleLineTestCase(ignored_cases[i]),
86 &entries));
87 EXPECT_EQ(0U, entries.size());
91 TEST_F(FtpDirectoryListingParserWindowsTest, Bad) {
92 const char* const bad_cases[] = {
93 "garbage",
94 "11-02-09 05:32PM <GARBAGE>",
95 "11-02-09 05:32PM <GARBAGE> NT",
96 "11-FEB-09 05:32PM <DIR>",
97 "11-02 05:32PM <DIR>",
98 "11-02-09 05:32PM -1",
99 "11-FEB-09 05:32PM <DIR> NT",
100 "11-02 05:32PM <DIR> NT",
101 "11-02-09 05:32PM -1 NT",
102 "99-25-10 12:00AM 0",
103 "12-99-10 12:00AM 0",
104 "12-25-10 99:00AM 0",
105 "12-25-10 12:99AM 0",
106 "12-25-10 12:00ZM 0",
107 "99-25-10 12:00AM 0 months 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",
113 for (size_t i = 0; i < arraysize(bad_cases); i++) {
114 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
115 bad_cases[i]));
117 std::vector<FtpDirectoryListingEntry> entries;
118 EXPECT_FALSE(ParseFtpDirectoryListingWindows(
119 GetSingleLineTestCase(bad_cases[i]),
120 &entries));
124 } // namespace
126 } // namespace net