| Index: base/command_line_unittest.cc
|
| diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc
|
| index 2c947fc39ad8a47a53b62b3ea21677b227cd07c1..f8b2e2c0cf3ed2ba6ffe93118ab09a94204f5622 100644
|
| --- a/base/command_line_unittest.cc
|
| +++ b/base/command_line_unittest.cc
|
| @@ -351,6 +351,68 @@ TEST(CommandLineTest, ProgramQuotes) {
|
| }
|
| #endif
|
|
|
| +TEST(CommandLineTest, RemoveSwitches) {
|
| + std::string switch1 = "switch1";
|
| + std::string switch2 = "switch2";
|
| + std::string value2 = "value";
|
| + std::string switch3 = "switch3";
|
| + std::string value3 = "a value with spaces";
|
| + std::string switch4 = "switch4";
|
| + std::string value4 = "\"a value with quotes\"";
|
| + std::string switch5 = "quotes";
|
| + CommandLine::StringType value5 = kTricky;
|
| +
|
| + CommandLine cl(FilePath(FILE_PATH_LITERAL("Program")));
|
| +
|
| + cl.AppendSwitch(switch1);
|
| + cl.AppendSwitchASCII(switch2, value2);
|
| + cl.AppendSwitchASCII(switch3, value3);
|
| + cl.AppendSwitchASCII(switch4, value4);
|
| + cl.AppendSwitchNative(switch5, value5);
|
| +
|
| + EXPECT_TRUE(cl.HasSwitch(switch1));
|
| + EXPECT_TRUE(cl.HasSwitch(switch2));
|
| + EXPECT_TRUE(cl.HasSwitch(switch3));
|
| + EXPECT_TRUE(cl.HasSwitch(switch4));
|
| + EXPECT_TRUE(cl.HasSwitch(switch5));
|
| +
|
| + // Ignore not-included switch.
|
| + cl.RemoveSwitch("ignore_switch");
|
| + EXPECT_TRUE(cl.HasSwitch(switch1));
|
| + EXPECT_TRUE(cl.HasSwitch(switch2));
|
| + EXPECT_TRUE(cl.HasSwitch(switch3));
|
| + EXPECT_TRUE(cl.HasSwitch(switch4));
|
| + EXPECT_TRUE(cl.HasSwitch(switch5));
|
| +
|
| + // Remove switches in the random order.
|
| + cl.RemoveSwitch(switch3);
|
| + EXPECT_FALSE(cl.HasSwitch(switch3));
|
| + EXPECT_TRUE(cl.HasSwitch(switch1));
|
| + EXPECT_TRUE(cl.HasSwitch(switch2));
|
| + EXPECT_TRUE(cl.HasSwitch(switch4));
|
| + EXPECT_TRUE(cl.HasSwitch(switch5));
|
| +
|
| + cl.RemoveSwitch(switch1);
|
| + EXPECT_FALSE(cl.HasSwitch(switch1));
|
| + EXPECT_TRUE(cl.HasSwitch(switch2));
|
| + EXPECT_TRUE(cl.HasSwitch(switch4));
|
| + EXPECT_TRUE(cl.HasSwitch(switch5));
|
| +
|
| + cl.RemoveSwitch(switch4);
|
| + EXPECT_FALSE(cl.HasSwitch(switch4));
|
| + EXPECT_TRUE(cl.HasSwitch(switch2));
|
| + EXPECT_TRUE(cl.HasSwitch(switch5));
|
| +
|
| + cl.RemoveSwitch(switch5);
|
| + EXPECT_FALSE(cl.HasSwitch(switch5));
|
| + EXPECT_TRUE(cl.HasSwitch(switch2));
|
| +
|
| + cl.RemoveSwitch(switch2);
|
| + EXPECT_FALSE(cl.HasSwitch(switch2));
|
| +
|
| + EXPECT_EQ(FILE_PATH_LITERAL("Program"), cl.GetCommandLineString());
|
| +}
|
| +
|
| // Calling Init multiple times should not modify the previous CommandLine.
|
| TEST(CommandLineTest, Init) {
|
| CommandLine* initial = CommandLine::ForCurrentProcess();
|
|
|