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