| OLD | NEW |
| 1 // Copyright (c) 2010 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_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" | 10 #include "base/stringprintf.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Expected output. | 118 // Expected output. |
| 119 int expected_year; | 119 int expected_year; |
| 120 int expected_month; | 120 int expected_month; |
| 121 int expected_day_of_month; | 121 int expected_day_of_month; |
| 122 int expected_hour; | 122 int expected_hour; |
| 123 int expected_minute; | 123 int expected_minute; |
| 124 } kTestCases[] = { | 124 } kTestCases[] = { |
| 125 { "Nov", "01", "2007", 2007, 11, 1, 0, 0 }, | 125 { "Nov", "01", "2007", 2007, 11, 1, 0, 0 }, |
| 126 { "Jul", "25", "13:37", 1994, 7, 25, 13, 37 }, | 126 { "Jul", "25", "13:37", 1994, 7, 25, 13, 37 }, |
| 127 | 127 |
| 128 // Test date listings in German, we should support them for FTP servers | 128 // Test date listings in German. |
| 129 // giving localized listings. | |
| 130 { "M\xc3\xa4r", "13", "2009", 2009, 3, 13, 0, 0 }, | 129 { "M\xc3\xa4r", "13", "2009", 2009, 3, 13, 0, 0 }, |
| 131 { "Mai", "1", "10:10", 1994, 5, 1, 10, 10 }, | 130 { "Mai", "1", "10:10", 1994, 5, 1, 10, 10 }, |
| 132 { "Okt", "14", "21:18", 1994, 10, 14, 21, 18 }, | 131 { "Okt", "14", "21:18", 1994, 10, 14, 21, 18 }, |
| 133 { "Dez", "25", "2008", 2008, 12, 25, 0, 0 }, | 132 { "Dez", "25", "2008", 2008, 12, 25, 0, 0 }, |
| 134 | 133 |
| 134 // Test date listings in Russian. |
| 135 { "\xd1\x8f\xd0\xbd\xd0\xb2", "1", "2011", 2011, 1, 1, 0, 0 }, |
| 136 { "\xd1\x84\xd0\xb5\xd0\xb2", "1", "2011", 2011, 2, 1, 0, 0 }, |
| 137 { "\xd0\xbc\xd0\xb0\xd1\x80", "1", "2011", 2011, 3, 1, 0, 0 }, |
| 138 { "\xd0\xb0\xd0\xbf\xd1\x80", "1", "2011", 2011, 4, 1, 0, 0 }, |
| 139 { "\xd0\xbc\xd0\xb0\xd0\xb9", "1", "2011", 2011, 5, 1, 0, 0 }, |
| 140 { "\xd0\xb8\xd1\x8e\xd0\xbd", "1", "2011", 2011, 6, 1, 0, 0 }, |
| 141 { "\xd0\xb8\xd1\x8e\xd0\xbb", "1", "2011", 2011, 7, 1, 0, 0 }, |
| 142 { "\xd0\xb0\xd0\xb2\xd0\xb3", "1", "2011", 2011, 8, 1, 0, 0 }, |
| 143 { "\xd1\x81\xd0\xb5\xd0\xbd", "1", "2011", 2011, 9, 1, 0, 0 }, |
| 144 { "\xd0\xbe\xd0\xba\xd1\x82", "1", "2011", 2011, 10, 1, 0, 0 }, |
| 145 { "\xd0\xbd\xd0\xbe\xd1\x8f", "1", "2011", 2011, 11, 1, 0, 0 }, |
| 146 { "\xd0\xb4\xd0\xb5\xd0\xba", "1", "2011", 2011, 12, 1, 0, 0 }, |
| 147 |
| 135 // Test current year detection. | 148 // Test current year detection. |
| 136 { "Nov", "01", "12:00", 1994, 11, 1, 12, 0 }, | 149 { "Nov", "01", "12:00", 1994, 11, 1, 12, 0 }, |
| 137 { "Nov", "15", "12:00", 1994, 11, 15, 12, 0 }, | 150 { "Nov", "15", "12:00", 1994, 11, 15, 12, 0 }, |
| 138 { "Nov", "16", "12:00", 1993, 11, 16, 12, 0 }, | 151 { "Nov", "16", "12:00", 1993, 11, 16, 12, 0 }, |
| 139 { "Jan", "01", "08:30", 1994, 1, 1, 8, 30 }, | 152 { "Jan", "01", "08:30", 1994, 1, 1, 8, 30 }, |
| 140 { "Sep", "02", "09:00", 1994, 9, 2, 9, 0 }, | 153 { "Sep", "02", "09:00", 1994, 9, 2, 9, 0 }, |
| 141 { "Dec", "06", "21:00", 1993, 12, 6, 21, 0 }, | 154 { "Dec", "06", "21:00", 1993, 12, 6, 21, 0 }, |
| 142 }; | 155 }; |
| 143 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { | 156 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { |
| 144 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %s %s", i, | 157 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %s %s", i, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %d", i, | 196 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %d", i, |
| 184 kTestCases[i].text, kTestCases[i].column)); | 197 kTestCases[i].text, kTestCases[i].column)); |
| 185 | 198 |
| 186 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_result), | 199 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_result), |
| 187 net::FtpUtil::GetStringPartAfterColumns( | 200 net::FtpUtil::GetStringPartAfterColumns( |
| 188 ASCIIToUTF16(kTestCases[i].text), kTestCases[i].column)); | 201 ASCIIToUTF16(kTestCases[i].text), kTestCases[i].column)); |
| 189 } | 202 } |
| 190 } | 203 } |
| 191 | 204 |
| 192 } // namespace | 205 } // namespace |
| OLD | NEW |