diff options
author | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-07 20:07:32 +0000 |
---|---|---|
committer | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-07 20:07:32 +0000 |
commit | f3adb5c4f36fd3233d0c0baad5eaef76da462a87 (patch) | |
tree | 2c468c275e56a060d397ad2d9ad407387c8c83a0 /base/command_line_unittest.cc | |
parent | c17be48b88e3c8614a333a27d79341de7aeeb684 (diff) | |
download | chromium_src-f3adb5c4f36fd3233d0c0baad5eaef76da462a87.zip chromium_src-f3adb5c4f36fd3233d0c0baad5eaef76da462a87.tar.gz chromium_src-f3adb5c4f36fd3233d0c0baad5eaef76da462a87.tar.bz2 |
Pinkerton's port/fix-up of command-line processing to work cross-platform.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@531 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/command_line_unittest.cc')
-rw-r--r-- | base/command_line_unittest.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc index dbcf06f..6a0a62c 100644 --- a/base/command_line_unittest.cc +++ b/base/command_line_unittest.cc @@ -31,6 +31,7 @@ #include <vector> #include "base/command_line.h" +#include "base/basictypes.h" #include "base/logging.h" #include "testing/gtest/include/gtest/gtest.h" @@ -40,12 +41,21 @@ namespace { }; TEST(CommandLineTest, CommandLineConstructor) { +#ifdef OS_WIN CommandLine cl(L"program --foo= -bAr /Spaetzel=pierogi /Baz flim " L"--other-switches=\"--dog=canine --cat=feline\" " L"-spaetzle=Crepe -=loosevalue flan " L"--input-translation=\"45\"--output-rotation " L"\"in the time of submarines...\""); - +#elif OS_POSIX + const char* argv[] = {"program", "--foo=", "-bAr", + "/Spaetzel=pierogi /Baz flim", + "--other-switches=\"--dog=canine --cat=feline\"", + "-spaetzle=Crepe", "-=loosevalue", "flan", + "--input-translation=\"45\"--output-rotation", + "\"in the time of submarines...\""}; + CommandLine cl(arraysize(argv), argv); +#endif EXPECT_FALSE(cl.command_line_string().empty()); EXPECT_FALSE(cl.HasSwitch(L"cruller")); EXPECT_FALSE(cl.HasSwitch(L"flim")); @@ -92,13 +102,21 @@ TEST(CommandLineTest, DefaultConstructor) { // Tests behavior with an empty input string. TEST(CommandLineTest, EmptyString) { +#if defined(OS_WIN) CommandLine cl(L""); +#elif defined(OS_POSIX) + const char* argv[] = {}; + CommandLine cl(ARRAYSIZE_UNSAFE(argv), argv); +#endif EXPECT_TRUE(cl.command_line_string().empty()); EXPECT_TRUE(cl.program().empty()); EXPECT_EQ(0, cl.GetLooseValueCount()); } // Test static functions for appending switches to a command line. +// TODO(pinkerton): non-windows platforms don't have the requisite ctor here, so +// we need something that tests AppendSwitches in another way (if even desired). +#if defined(OS_WIN) TEST(CommandLineTest, AppendSwitches) { std::wstring cl_string = L"Program"; std::wstring switch1 = L"switch1"; @@ -123,3 +141,4 @@ TEST(CommandLineTest, AppendSwitches) { EXPECT_TRUE(cl.HasSwitch(switch2)); EXPECT_EQ(value4.substr(1, value4.length() - 2), cl.GetSwitchValue(switch4)); } +#endif |