diff options
-rw-r--r-- | base/command_line.cc | 3 | ||||
-rw-r--r-- | base/command_line.h | 2 | ||||
-rw-r--r-- | base/command_line_unittest.cc | 10 |
3 files changed, 8 insertions, 7 deletions
diff --git a/base/command_line.cc b/base/command_line.cc index 3e143cc..61ff5c1 100644 --- a/base/command_line.cc +++ b/base/command_line.cc @@ -263,7 +263,8 @@ void CommandLine::SetProgram(const FilePath& program) { } bool CommandLine::HasSwitch(const std::string& switch_string) const { - return switches_.find(LowerASCIIOnWindows(switch_string)) != switches_.end(); + DCHECK_EQ(StringToLowerASCII(switch_string), switch_string); + return switches_.find(switch_string) != switches_.end(); } bool CommandLine::HasSwitch(const char string_constant[]) const { diff --git a/base/command_line.h b/base/command_line.h index 19df40c..439921e 100644 --- a/base/command_line.h +++ b/base/command_line.h @@ -142,7 +142,7 @@ class BASE_EXPORT CommandLine { void SetProgram(const FilePath& program); // Returns true if this command line contains the given switch. - // (Switch names are case-insensitive). + // Switch names should only be lowercase. // The second override provides an optimized version to avoid inlining the // codegen for the string allocation. bool HasSwitch(const std::string& switch_string) const; diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc index e395c856..db1a0b2 100644 --- a/base/command_line_unittest.cc +++ b/base/command_line_unittest.cc @@ -60,12 +60,13 @@ TEST(CommandLineTest, CommandLineConstructor) { cl.GetProgram().value()); EXPECT_TRUE(cl.HasSwitch("foo")); - EXPECT_TRUE(cl.HasSwitch("bAr")); - EXPECT_TRUE(cl.HasSwitch("baz")); - EXPECT_TRUE(cl.HasSwitch("spaetzle")); #if defined(OS_WIN) - EXPECT_TRUE(cl.HasSwitch("SPAETZLE")); + EXPECT_TRUE(cl.HasSwitch("bar")); +#else + EXPECT_FALSE(cl.HasSwitch("bar")); #endif + EXPECT_TRUE(cl.HasSwitch("baz")); + EXPECT_TRUE(cl.HasSwitch("spaetzle")); EXPECT_TRUE(cl.HasSwitch("other-switches")); EXPECT_TRUE(cl.HasSwitch("input-translation")); @@ -128,7 +129,6 @@ TEST(CommandLineTest, CommandLineFromString) { EXPECT_TRUE(cl.HasSwitch("bar")); EXPECT_TRUE(cl.HasSwitch("baz")); EXPECT_TRUE(cl.HasSwitch("spaetzle")); - EXPECT_TRUE(cl.HasSwitch("SPAETZLE")); EXPECT_TRUE(cl.HasSwitch("other-switches")); EXPECT_TRUE(cl.HasSwitch("input-translation")); EXPECT_TRUE(cl.HasSwitch("quotes")); |