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

Unified Diff: net/ftp/ftp_directory_listing_buffer_unittest.cc

Issue 1120012: Fix the "ls -l" style date parser to correctly guess the year if it is not provided. (Closed)
Patch Set: better comments Created 10 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer.cc ('k') | net/ftp/ftp_directory_listing_parser_ls.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_directory_listing_buffer_unittest.cc
diff --git a/net/ftp/ftp_directory_listing_buffer_unittest.cc b/net/ftp/ftp_directory_listing_buffer_unittest.cc
index 0d144f58e4a20f397fd81d0b3947a6093162719a..d9708d5f09b1c42dfb01599c95cfb12eb0411164 100644
--- a/net/ftp/ftp_directory_listing_buffer_unittest.cc
+++ b/net/ftp/ftp_directory_listing_buffer_unittest.cc
@@ -54,10 +54,14 @@ TEST(FtpDirectoryListingBufferTest, Parse) {
test_dir = test_dir.AppendASCII("data");
test_dir = test_dir.AppendASCII("ftp");
+ base::Time mock_current_time;
+ ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT",
+ &mock_current_time));
+
for (size_t i = 0; i < arraysize(test_files); i++) {
SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, test_files[i]));
- net::FtpDirectoryListingBuffer buffer;
+ net::FtpDirectoryListingBuffer buffer(mock_current_time);
std::string test_listing;
EXPECT_TRUE(file_util::ReadFileToString(test_dir.AppendASCII(test_files[i]),
@@ -85,14 +89,7 @@ TEST(FtpDirectoryListingBufferTest, Parse) {
SCOPED_TRACE(StringPrintf("Filename: %s", name.c_str()));
- int year;
- if (lines[8 * i + 3] == "current") {
- base::Time::Exploded now_exploded;
- base::Time::Now().LocalExplode(&now_exploded);
- year = now_exploded.year;
- } else {
- year = StringToInt(lines[8 * i + 3]);
- }
+ int year = StringToInt(lines[8 * i + 3]);
int month = StringToInt(lines[8 * i + 4]);
int day_of_month = StringToInt(lines[8 * i + 5]);
int hour = StringToInt(lines[8 * i + 6]);
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer.cc ('k') | net/ftp/ftp_directory_listing_parser_ls.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698