Index: base/command_line_unittest.cc |
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc |
index d93ffb89873dca7ae0397203219977e84c74786b..d2f6beadc4ac217ca52d247eda410c544ffe4ac7 100644 |
--- a/base/command_line_unittest.cc |
+++ b/base/command_line_unittest.cc |
@@ -178,6 +178,50 @@ 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"; |
+ |
+ CommandLine cl(CommandLine::NO_PROGRAM); |
+ cl.AppendSwitchPath(kFirstArgName, FilePath(kPath1)); |
+ cl.AppendSwitchPath(kSecondArgName, FilePath(kPath2)); |
robertshield
2012/10/29 02:04:43
should have something in this test that exercises
gab
2012/10/29 15:50:44
Done.
|
+ |
+#if defined(OS_WIN) |
+ CommandLine::StringType expected_first_arg(UTF8ToUTF16(kFirstArgName)); |
+ CommandLine::StringType expected_second_arg(UTF8ToUTF16(kSecondArgName)); |
+#elif defined(OS_POSIX) |
+ CommandLine::StringType expected_first_arg(kFirstArgName); |
+ CommandLine::StringType expected_second_arg(kSecondArgName); |
+#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); |
+ EXPECT_EQ(expected_str, cl.GetArgumentsString()); |
+} |
+ |
// Test methods for appending switches to a command line. |
TEST(CommandLineTest, AppendSwitches) { |
std::string switch1 = "switch1"; |