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

Unified Diff: net/ftp/ftp_directory_listing_parser_netware_unittest.cc

Issue 465059: Implement parser for Netware-style FTP LIST response listing. (Closed)
Patch Set: Created 11 years 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
Index: net/ftp/ftp_directory_listing_parser_netware_unittest.cc
diff --git a/net/ftp/ftp_directory_listing_parser_netware_unittest.cc b/net/ftp/ftp_directory_listing_parser_netware_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7076a3fb35995cac88f9cc008ebf79f5cf3fa582
--- /dev/null
+++ b/net/ftp/ftp_directory_listing_parser_netware_unittest.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/ftp/ftp_directory_listing_parser_unittest.h"
+
+#include "base/format_macros.h"
+#include "net/ftp/ftp_directory_listing_parser_netware.h"
+
+namespace {
+
+typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserNetwareTest;
+
+TEST_F(FtpDirectoryListingParserNetwareTest, Good) {
+ base::Time::Exploded now_exploded;
+ base::Time::Now().LocalExplode(&now_exploded);
+
+ const struct SingleLineTestData good_cases[] = {
+ { "d [RWCEAFMS] ftpadmin 512 Jan 29 2004 pub",
+ net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1,
+ 2004, 1, 29, 0, 0 },
+ { "- [RW------] ftpadmin 123 Nov 11 18:25 afile",
+ net::FtpDirectoryListingEntry::FILE, "afile", 123,
+ now_exploded.year, 11, 11, 18, 25 },
+ };
+ 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
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input));
eroman 2009/12/07 19:15:54 yuck, PRIus :(
+
+ net::FtpDirectoryListingParserNetware parser;
+ // The parser requires a "total n" like before accepting regular input.
+ ASSERT_TRUE(parser.ConsumeLine(UTF8ToUTF16("total 1")));
+ RunSingleLineTestCase(&parser, good_cases[i]);
+ }
+}
+
+TEST_F(FtpDirectoryListingParserNetwareTest, Bad) {
+ const char* bad_cases[] = {
+ "garbage",
+ "d [] ftpadmin 512 Jan 29 2004 pub",
+ "d [XGARBAGE] ftpadmin 512 Jan 29 2004 pub",
+ "d [RWCEAFMS] 512 Jan 29 2004 pub",
+ "d [RWCEAFMS] ftpadmin -1 Jan 29 2004 pub",
+ "l [RW------] ftpadmin 512 Jan 29 2004 pub",
+ };
+ for (size_t i = 0; i < arraysize(bad_cases); i++) {
+ net::FtpDirectoryListingParserNetware parser;
+ // The parser requires a "total n" like before accepting regular input.
+ ASSERT_TRUE(parser.ConsumeLine(UTF8ToUTF16("total 1")));
+ EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i];
+ }
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698