| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_util.h" | 5 #include "net/ftp/ftp_util.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" |
| 11 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 11 #include "base/time.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 TEST(FtpUtilTest, UnixFilePathToVMS) { | 17 TEST(FtpUtilTest, UnixFilePathToVMS) { |
| 17 const struct { | 18 const struct { |
| 18 const char* input; | 19 const char* input; |
| 19 const char* expected_output; | 20 const char* expected_output; |
| 20 } kTestCases[] = { | 21 } kTestCases[] = { |
| 21 { "", "" }, | 22 { "", "" }, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 134 |
| 134 // Test current year detection. | 135 // Test current year detection. |
| 135 { "Nov", "01", "12:00", 1994, 11, 1, 12, 0 }, | 136 { "Nov", "01", "12:00", 1994, 11, 1, 12, 0 }, |
| 136 { "Nov", "15", "12:00", 1994, 11, 15, 12, 0 }, | 137 { "Nov", "15", "12:00", 1994, 11, 15, 12, 0 }, |
| 137 { "Nov", "16", "12:00", 1993, 11, 16, 12, 0 }, | 138 { "Nov", "16", "12:00", 1993, 11, 16, 12, 0 }, |
| 138 { "Jan", "01", "08:30", 1994, 1, 1, 8, 30 }, | 139 { "Jan", "01", "08:30", 1994, 1, 1, 8, 30 }, |
| 139 { "Sep", "02", "09:00", 1994, 9, 2, 9, 0 }, | 140 { "Sep", "02", "09:00", 1994, 9, 2, 9, 0 }, |
| 140 { "Dec", "06", "21:00", 1993, 12, 6, 21, 0 }, | 141 { "Dec", "06", "21:00", 1993, 12, 6, 21, 0 }, |
| 141 }; | 142 }; |
| 142 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { | 143 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { |
| 143 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s %s %s", i, | 144 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %s %s", i, |
| 144 kTestCases[i].month, kTestCases[i].day, | 145 kTestCases[i].month, kTestCases[i].day, |
| 145 kTestCases[i].rest)); | 146 kTestCases[i].rest)); |
| 146 | 147 |
| 147 base::Time time; | 148 base::Time time; |
| 148 ASSERT_TRUE(net::FtpUtil::LsDateListingToTime( | 149 ASSERT_TRUE(net::FtpUtil::LsDateListingToTime( |
| 149 UTF8ToUTF16(kTestCases[i].month), UTF8ToUTF16(kTestCases[i].day), | 150 UTF8ToUTF16(kTestCases[i].month), UTF8ToUTF16(kTestCases[i].day), |
| 150 UTF8ToUTF16(kTestCases[i].rest), mock_current_time, &time)); | 151 UTF8ToUTF16(kTestCases[i].rest), mock_current_time, &time)); |
| 151 | 152 |
| 152 base::Time::Exploded time_exploded; | 153 base::Time::Exploded time_exploded; |
| 153 time.LocalExplode(&time_exploded); | 154 time.LocalExplode(&time_exploded); |
| 154 EXPECT_EQ(kTestCases[i].expected_year, time_exploded.year); | 155 EXPECT_EQ(kTestCases[i].expected_year, time_exploded.year); |
| 155 EXPECT_EQ(kTestCases[i].expected_month, time_exploded.month); | 156 EXPECT_EQ(kTestCases[i].expected_month, time_exploded.month); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 172 { "foo abc", 0, "foo abc" }, | 173 { "foo abc", 0, "foo abc" }, |
| 173 { "foo abc", 1, "abc" }, | 174 { "foo abc", 1, "abc" }, |
| 174 { " foo abc", 0, "foo abc" }, | 175 { " foo abc", 0, "foo abc" }, |
| 175 { " foo abc", 1, "abc" }, | 176 { " foo abc", 1, "abc" }, |
| 176 { " foo abc", 2, "" }, | 177 { " foo abc", 2, "" }, |
| 177 { " foo abc ", 0, "foo abc" }, | 178 { " foo abc ", 0, "foo abc" }, |
| 178 { " foo abc ", 1, "abc" }, | 179 { " foo abc ", 1, "abc" }, |
| 179 { " foo abc ", 2, "" }, | 180 { " foo abc ", 2, "" }, |
| 180 }; | 181 }; |
| 181 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { | 182 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { |
| 182 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s %d", | 183 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %d", i, |
| 183 i, kTestCases[i].text, kTestCases[i].column)); | 184 kTestCases[i].text, kTestCases[i].column)); |
| 184 | 185 |
| 185 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_result), | 186 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_result), |
| 186 net::FtpUtil::GetStringPartAfterColumns( | 187 net::FtpUtil::GetStringPartAfterColumns( |
| 187 ASCIIToUTF16(kTestCases[i].text), kTestCases[i].column)); | 188 ASCIIToUTF16(kTestCases[i].text), kTestCases[i].column)); |
| 188 } | 189 } |
| 189 } | 190 } |
| 190 | 191 |
| 191 } // namespace | 192 } // namespace |
| OLD | NEW |