Index: base/command_line_unittest.cc |
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc |
index d93ffb89873dca7ae0397203219977e84c74786b..372af37a3d12c3d2274ad68b7db6ee84b3a81b1f 100644 |
--- a/base/command_line_unittest.cc |
+++ b/base/command_line_unittest.cc |
@@ -178,6 +178,64 @@ TEST(CommandLineTest, EmptyString) { |
EXPECT_TRUE(cl_from_argv.GetArgs().empty()); |
} |
+TEST(CommandLineTest, GetArgumentsString) { |
+ static const FilePath::CharType kPath1[] = |
+ FILE_PATH_LITERAL("C:\\Some File\\With Spaces.ggg"); |
+ static const FilePath::CharType kPath2[] = |
+ FILE_PATH_LITERAL("C:\\no\\spaces.ggg"); |
+ |
+ static const char kFirstArgName[] = "first-arg"; |
+ static const char kSecondArgName[] = "arg2"; |
+ static const char kThirdArgName[] = "arg with space"; |
+ static const char kFourthArgName[] = "nospace"; |
+ |
+ CommandLine cl(CommandLine::NO_PROGRAM); |
+ cl.AppendSwitchPath(kFirstArgName, FilePath(kPath1)); |
+ cl.AppendSwitchPath(kSecondArgName, FilePath(kPath2)); |
+ cl.AppendArg(kThirdArgName); |
+ cl.AppendArg(kFourthArgName); |
+ |
+#if defined(OS_WIN) |
+ CommandLine::StringType expected_first_arg(UTF8ToUTF16(kFirstArgName)); |
+ CommandLine::StringType expected_second_arg(UTF8ToUTF16(kSecondArgName)); |
+ CommandLine::StringType expected_third_arg(UTF8ToUTF16(kThirdArgName)); |
+ CommandLine::StringType expected_fourth_arg(UTF8ToUTF16(kFourthArgName)); |
+#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); |
+#endif |
+ |
+#if defined(OS_WIN) |
+#define QUOTE_ON_WIN FILE_PATH_LITERAL("\"") |
+#else |
+#define QUOTE_ON_WIN FILE_PATH_LITERAL("") |
+#endif // OS_WIN |
+ |
+ CommandLine::StringType expected_str; |
+ expected_str.append(FILE_PATH_LITERAL("--")) |
+ .append(expected_first_arg) |
+ .append(FILE_PATH_LITERAL("=")) |
+ .append(QUOTE_ON_WIN) |
+ .append(kPath1) |
+ .append(QUOTE_ON_WIN) |
+ .append(FILE_PATH_LITERAL(" ")) |
+ .append(FILE_PATH_LITERAL("--")) |
+ .append(expected_second_arg) |
+ .append(FILE_PATH_LITERAL("=")) |
+ .append(QUOTE_ON_WIN) |
+ .append(kPath2) |
+ .append(QUOTE_ON_WIN) |
+ .append(FILE_PATH_LITERAL(" ")) |
+ .append(QUOTE_ON_WIN) |
+ .append(expected_third_arg) |
+ .append(QUOTE_ON_WIN) |
+ .append(FILE_PATH_LITERAL(" ")) |
+ .append(expected_fourth_arg); |
+ EXPECT_EQ(expected_str, cl.GetArgumentsString()); |
+} |
+ |
// Test methods for appending switches to a command line. |
TEST(CommandLineTest, AppendSwitches) { |
std::string switch1 = "switch1"; |