Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/ftp/ftp_directory_listing_parser_unittest.h" | |
| 6 | |
| 7 #include "base/format_macros.h" | |
| 8 #include "net/ftp/ftp_directory_listing_parser_netware.h" | |
| 9 | |
| 10 namespace { | |
| 11 | |
| 12 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserNetwareTest; | |
| 13 | |
| 14 TEST_F(FtpDirectoryListingParserNetwareTest, Good) { | |
| 15 base::Time::Exploded now_exploded; | |
| 16 base::Time::Now().LocalExplode(&now_exploded); | |
| 17 | |
| 18 const struct SingleLineTestData good_cases[] = { | |
| 19 { "d [RWCEAFMS] ftpadmin 512 Jan 29 2004 pub", | |
| 20 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, | |
| 21 2004, 1, 29, 0, 0 }, | |
| 22 { "- [RW------] ftpadmin 123 Nov 11 18:25 afile", | |
| 23 net::FtpDirectoryListingEntry::FILE, "afile", 123, | |
| 24 now_exploded.year, 11, 11, 18, 25 }, | |
| 25 }; | |
| 26 for (size_t i = 0; i < arraysize(good_cases); i++) { | |
|
wtc
2009/12/08 01:50:35
You can declare i as unsigned int instead of size_
Peter Kasting
2009/12/08 01:57:13
Google style guide forbids this. size_t is the co
| |
| 27 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); | |
|
eroman
2009/12/07 19:15:54
yuck, PRIus :(
| |
| 28 | |
| 29 net::FtpDirectoryListingParserNetware parser; | |
| 30 // The parser requires a "total n" like before accepting regular input. | |
| 31 ASSERT_TRUE(parser.ConsumeLine(UTF8ToUTF16("total 1"))); | |
| 32 RunSingleLineTestCase(&parser, good_cases[i]); | |
| 33 } | |
| 34 } | |
| 35 | |
| 36 TEST_F(FtpDirectoryListingParserNetwareTest, Bad) { | |
| 37 const char* bad_cases[] = { | |
| 38 "garbage", | |
| 39 "d [] ftpadmin 512 Jan 29 2004 pub", | |
| 40 "d [XGARBAGE] ftpadmin 512 Jan 29 2004 pub", | |
| 41 "d [RWCEAFMS] 512 Jan 29 2004 pub", | |
| 42 "d [RWCEAFMS] ftpadmin -1 Jan 29 2004 pub", | |
| 43 "l [RW------] ftpadmin 512 Jan 29 2004 pub", | |
| 44 }; | |
| 45 for (size_t i = 0; i < arraysize(bad_cases); i++) { | |
| 46 net::FtpDirectoryListingParserNetware parser; | |
| 47 // The parser requires a "total n" like before accepting regular input. | |
| 48 ASSERT_TRUE(parser.ConsumeLine(UTF8ToUTF16("total 1"))); | |
| 49 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 } // namespace | |
| OLD | NEW |