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

Unified Diff: base/command_line_unittest.cc

Issue 4949004: Add a unit test for CommandLine that makes sure that GetProgram will not retu... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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
« base/command_line.cc ('K') | « base/command_line.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/command_line_unittest.cc
===================================================================
--- base/command_line_unittest.cc (revision 66131)
+++ base/command_line_unittest.cc (working copy)
@@ -179,3 +179,30 @@
EXPECT_TRUE(c1.HasSwitch("switch2"));
}
+// Make sure that the program part of a command line is always quoted.
+TEST(CommandLineTest, ProgramQuotes) {
+ const FilePath kProgram(FILE_PATH_LITERAL("Program"));
+ const FilePath kProgramQuoted(FILE_PATH_LITERAL("\"Program\""));
+
+ // Check that quotes are not returned from GetProgram().
+ CommandLine cl1(kProgram);
+ EXPECT_EQ(kProgram.value(), cl1.GetProgram().value());
+
+ CommandLine cl2(kProgramQuoted);
+ EXPECT_EQ(kProgram.value(), cl2.GetProgram().value());
+
+ CommandLine cl3(CommandLine::FromString(kProgramQuoted.value()));
+ EXPECT_EQ(kProgram.value(), cl3.GetProgram().value());
+
+#if defined(OS_WIN)
+ // Verify that in the command line string, the program part is always quoted.
+ CommandLine* check[] = {&cl1, &cl2, &cl3};
+ for (int i = 0; i < arraysize(check); ++i) {
+ CommandLine::StringType c(check[i]->command_line_string());
+ CommandLine::StringType p(check[i]->GetProgram().value());
+ EXPECT_EQ('"', c[0]);
+ EXPECT_EQ(p, c.substr(1, p.length()));
+ EXPECT_EQ('"', c[p.length() + 1]);
+ }
+#endif
+}
« base/command_line.cc ('K') | « base/command_line.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698