commit | b1d5fcb39d507d2ef69b4905895815b80e94b19b | [log] [tgz] |
---|---|---|
author | John Rummell <[email protected]> | Sat Apr 27 01:13:33 2019 |
committer | Commit Bot <[email protected]> | Sat Apr 27 01:13:33 2019 |
tree | 118d65f6ce86dd006aa7e98227d3f3b590da7d2f | |
parent | 542bee1e45eb2a57e92dfe642c7a969692479608 [diff] [blame] |
Note that only the last value of a switch is used by CommandLine. Also adds a test to verify the behavior. BUG=957138 TEST=new base_unittest passes Change-Id: Ida1d0801f457e96dbf1d2ed299966a50aec05442 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1586220 Commit-Queue: Daniel Cheng <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Cr-Commit-Position: refs/heads/master@{#654698}
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc index aa69cd9..26a045b 100644 --- a/base/command_line_unittest.cc +++ b/base/command_line_unittest.cc
@@ -461,4 +461,19 @@ EXPECT_EQ(value2, cl.GetSwitchValueASCII(switch2)); } +TEST(CommandLineTest, MultipleSameSwitch) { + const CommandLine::CharType* argv[] = { + FILE_PATH_LITERAL("program"), + FILE_PATH_LITERAL("--foo=one"), // --foo first time + FILE_PATH_LITERAL("-baz"), + FILE_PATH_LITERAL("--foo=two") // --foo second time + }; + CommandLine cl(size(argv), argv); + + EXPECT_TRUE(cl.HasSwitch("foo")); + EXPECT_TRUE(cl.HasSwitch("baz")); + + EXPECT_EQ("two", cl.GetSwitchValueASCII("foo")); +} + } // namespace base