| Index: chrome/install_static/install_util_unittest.cc
|
| diff --git a/chrome/install_static/install_util_unittest.cc b/chrome/install_static/install_util_unittest.cc
|
| index 0af8488d2651d598c7bb37b94658c2f45a1a711a..13131d11d024c2b9436f58ae9e15a7ee9a9138e4 100644
|
| --- a/chrome/install_static/install_util_unittest.cc
|
| +++ b/chrome/install_static/install_util_unittest.cc
|
| @@ -130,4 +130,68 @@ TEST(InstallStaticTest, CompareVersions) {
|
| EXPECT_EQ(-1, result);
|
| }
|
|
|
| +// Tests the install_static::GetSwitchValueFromCommandLine function.
|
| +TEST(InstallStaticTest, GetSwitchValueFromCommandLineTest) {
|
| + // Simple case with one switch.
|
| + std::string value =
|
| + GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=bar", "type");
|
| + EXPECT_EQ("bar", value);
|
| +
|
| + // Multiple switches with trailing spaces between them.
|
| + value = GetSwitchValueFromCommandLine(
|
| + "c:\\temp\\bleh.exe --type=bar --abc=def bleh", "abc");
|
| + EXPECT_EQ("def", value);
|
| +
|
| + // Multiple switches with trailing spaces and tabs between them.
|
| + value = GetSwitchValueFromCommandLine(
|
| + "c:\\temp\\bleh.exe --type=bar \t\t\t --abc=def bleh", "abc");
|
| + EXPECT_EQ("def", value);
|
| +
|
| + // Non existent switch.
|
| + value = GetSwitchValueFromCommandLine(
|
| + "c:\\temp\\bleh.exe --foo=bar --abc=def bleh", "type");
|
| + EXPECT_EQ("", value);
|
| +
|
| + // Non existent switch.
|
| + value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe", "type");
|
| + EXPECT_EQ("", value);
|
| +
|
| + // Non existent switch.
|
| + value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe type=bar", "type");
|
| + EXPECT_EQ("", value);
|
| +
|
| + // Trailing spaces after the switch.
|
| + value = GetSwitchValueFromCommandLine(
|
| + "c:\\temp\\bleh.exe --type=bar \t\t", "type");
|
| + EXPECT_EQ("bar", value);
|
| +
|
| + // Multiple switches with trailing spaces and tabs between them.
|
| + value = GetSwitchValueFromCommandLine(
|
| + "c:\\temp\\bleh.exe --type=bar \t\t --foo=bleh", "foo");
|
| + EXPECT_EQ("bleh", value);
|
| +
|
| + // Nothing after a switch.
|
| + value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=", "type");
|
| + EXPECT_TRUE(value.empty());
|
| +
|
| + // Whitespace after a switch.
|
| + value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type= ", "type");
|
| + EXPECT_TRUE(value.empty());
|
| +
|
| + // Just tabs after a switch.
|
| + value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=\t\t\t",
|
| + "type");
|
| + EXPECT_TRUE(value.empty());
|
| +
|
| + // Whitespace after the "=" before the value.
|
| + value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type= bar",
|
| + "type");
|
| + EXPECT_EQ("bar", value);
|
| +
|
| + // Tabs after the "=" before the value.
|
| + value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=\t\t\tbar",
|
| + "type");
|
| + EXPECT_EQ(value, "bar");
|
| +}
|
| +
|
| } // namespace install_static
|
|
|