diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-29 21:12:22 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-29 21:12:22 +0000 |
commit | 450b34ecabc9d41772b603008a060f81ec09a738 (patch) | |
tree | 435c95a7734e3a3877ea12bb061c511313117a5b /base | |
parent | ce3fb219c2dcfd853976981254116344b9813944 (diff) | |
download | chromium_src-450b34ecabc9d41772b603008a060f81ec09a738.zip chromium_src-450b34ecabc9d41772b603008a060f81ec09a738.tar.gz chromium_src-450b34ecabc9d41772b603008a060f81ec09a738.tar.bz2 |
Add a unit test for CommandLine that makes sure that GetProgram will not return a quoted string and that (on Windows) the program part of a command line string will always be quoted.
BUG=none
TEST=Run the ProgramQuotes test. Should be no visible changes.
Review URL: http://codereview.chromium.org/4949004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/command_line_unittest.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc index 5c525ae..6fd6440 100644 --- a/base/command_line_unittest.cc +++ b/base/command_line_unittest.cc @@ -179,3 +179,22 @@ TEST(CommandLineTest, AppendArguments) { EXPECT_TRUE(c1.HasSwitch("switch2")); } +#if defined(OS_WIN) +// Make sure that the program part of a command line is always quoted. +// This only makes sense on Windows and the test is basically here to guard +// against regressions. +TEST(CommandLineTest, ProgramQuotes) { + const FilePath kProgram(L"Program"); + + // Check that quotes are not returned from GetProgram(). + CommandLine cl(kProgram); + EXPECT_EQ(kProgram.value(), cl.GetProgram().value()); + + // Verify that in the command line string, the program part is always quoted. + CommandLine::StringType cmd(cl.command_line_string()); + CommandLine::StringType program(cl.GetProgram().value()); + EXPECT_EQ('"', cmd[0]); + EXPECT_EQ(program, cmd.substr(1, program.length())); + EXPECT_EQ('"', cmd[program.length() + 1]); +} +#endif |