diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-11 00:18:12 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-11 00:18:12 +0000 |
commit | 4c60ea0a14d9244f7e2cf95b670f503b2085786f (patch) | |
tree | 1db49fb31fafe168ee360a6c173fffbe4e1ecb04 /net/ftp/ftp_util_unittest.cc | |
parent | 49308e282f35009310c4d8e904bfa5e07f52647b (diff) | |
download | chromium_src-4c60ea0a14d9244f7e2cf95b670f503b2085786f.zip chromium_src-4c60ea0a14d9244f7e2cf95b670f503b2085786f.tar.gz chromium_src-4c60ea0a14d9244f7e2cf95b670f503b2085786f.tar.bz2 |
FTP: add directory listing parser for OS/2 format.
BUG=92154
TEST=navigate to ftp://ftp.os4.su/ - no errors should appear
Review URL: http://codereview.chromium.org/7590011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96275 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp/ftp_util_unittest.cc')
-rw-r--r-- | net/ftp/ftp_util_unittest.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/net/ftp/ftp_util_unittest.cc b/net/ftp/ftp_util_unittest.cc index 94c1837..fa7213e 100644 --- a/net/ftp/ftp_util_unittest.cc +++ b/net/ftp/ftp_util_unittest.cc @@ -175,6 +175,47 @@ TEST(FtpUtilTest, LsDateListingToTime) { } } +TEST(FtpUtilTest, WindowsDateListingToTime) { + const struct { + // Input. + const char* date; + const char* time; + + // Expected output. + int expected_year; + int expected_month; + int expected_day_of_month; + int expected_hour; + int expected_minute; + } kTestCases[] = { + { "11-01-07", "12:42", 2007, 11, 1, 12, 42 }, + { "11-01-07", "12:42AM", 2007, 11, 1, 0, 42 }, + { "11-01-07", "12:42PM", 2007, 11, 1, 12, 42 }, + + { "11-01-2007", "12:42", 2007, 11, 1, 12, 42 }, + }; + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { + SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %s", i, + kTestCases[i].date, kTestCases[i].time)); + + base::Time time; + ASSERT_TRUE(net::FtpUtil::WindowsDateListingToTime( + UTF8ToUTF16(kTestCases[i].date), + UTF8ToUTF16(kTestCases[i].time), + &time)); + + base::Time::Exploded time_exploded; + time.LocalExplode(&time_exploded); + EXPECT_EQ(kTestCases[i].expected_year, time_exploded.year); + EXPECT_EQ(kTestCases[i].expected_month, time_exploded.month); + EXPECT_EQ(kTestCases[i].expected_day_of_month, time_exploded.day_of_month); + EXPECT_EQ(kTestCases[i].expected_hour, time_exploded.hour); + EXPECT_EQ(kTestCases[i].expected_minute, time_exploded.minute); + EXPECT_EQ(0, time_exploded.second); + EXPECT_EQ(0, time_exploded.millisecond); + } +} + TEST(FtpUtilTest, GetStringPartAfterColumns) { const struct { const char* text; |