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

Unified Diff: base/command_line_unittest.cc

Issue 595803002: base::CommandLine: Added optional quoting of placeholder arguments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase off CL 602253006. Created 6 years, 3 months 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
« no previous file with comments | « 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
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc
index 8aed618858ebc8606aebedf1af0763fd70c0692c..8fdd605db79249f31179fababa00c706f9cbb263 100644
--- a/base/command_line_unittest.cc
+++ b/base/command_line_unittest.cc
@@ -190,12 +190,14 @@ TEST(CommandLineTest, GetArgumentsString) {
static const char kSecondArgName[] = "arg2";
static const char kThirdArgName[] = "arg with space";
static const char kFourthArgName[] = "nospace";
+ static const char kFifthArgName[] = "%1";
CommandLine cl(CommandLine::NO_PROGRAM);
cl.AppendSwitchPath(kFirstArgName, FilePath(kPath1));
cl.AppendSwitchPath(kSecondArgName, FilePath(kPath2));
cl.AppendArg(kThirdArgName);
cl.AppendArg(kFourthArgName);
+ cl.AppendArg(kFifthArgName);
#if defined(OS_WIN)
CommandLine::StringType expected_first_arg(
@@ -206,11 +208,13 @@ TEST(CommandLineTest, GetArgumentsString) {
base::UTF8ToUTF16(kThirdArgName));
CommandLine::StringType expected_fourth_arg(
base::UTF8ToUTF16(kFourthArgName));
+ CommandLine::StringType expected_fifth_arg(base::UTF8ToUTF16(kFifthArgName));
#elif defined(OS_POSIX)
CommandLine::StringType expected_first_arg(kFirstArgName);
CommandLine::StringType expected_second_arg(kSecondArgName);
CommandLine::StringType expected_third_arg(kThirdArgName);
CommandLine::StringType expected_fourth_arg(kFourthArgName);
+ CommandLine::StringType expected_fifth_arg(kFifthArgName);
#endif
#if defined(OS_WIN)
@@ -238,8 +242,21 @@ TEST(CommandLineTest, GetArgumentsString) {
.append(expected_third_arg)
.append(QUOTE_ON_WIN)
.append(FILE_PATH_LITERAL(" "))
- .append(expected_fourth_arg);
- EXPECT_EQ(expected_str, cl.GetArgumentsString());
+ .append(expected_fourth_arg)
+ .append(FILE_PATH_LITERAL(" "));
+
+ CommandLine::StringType expected_str_no_quote_placeholders(expected_str);
+ expected_str_no_quote_placeholders.append(expected_fifth_arg);
+ EXPECT_EQ(expected_str_no_quote_placeholders, cl.GetArgumentsString());
+
+#if defined(OS_WIN)
+ CommandLine::StringType expected_str_quote_placeholders(expected_str);
+ expected_str_quote_placeholders.append(QUOTE_ON_WIN)
+ .append(expected_fifth_arg)
+ .append(QUOTE_ON_WIN);
+ EXPECT_EQ(expected_str_quote_placeholders,
+ cl.GetArgumentsStringWithPlaceholders());
+#endif
}
// Test methods for appending switches to a command line.
@@ -349,6 +366,12 @@ TEST(CommandLineTest, ProgramQuotes) {
// Check that quotes are added to command line string paths containing spaces.
CommandLine::StringType cmd_string(cl_program_path.GetCommandLineString());
EXPECT_EQ(L"\"Program Path\"", cmd_string);
+
+ // Check the optional quoting of placeholders in programs.
+ CommandLine cl_quote_placeholder(base::FilePath(L"%1"));
+ EXPECT_EQ(L"%1", cl_quote_placeholder.GetCommandLineString());
+ EXPECT_EQ(L"\"%1\"",
+ cl_quote_placeholder.GetCommandLineStringWithPlaceholders());
}
#endif
« no previous file with comments | « base/command_line.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698