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

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

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

Powered by Google App Engine
This is Rietveld 408576698