OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 EXPECT_EQ(0, argvec[i].compare(argv[i])); | 99 EXPECT_EQ(0, argvec[i].compare(argv[i])); |
100 } | 100 } |
101 #endif | 101 #endif |
102 } | 102 } |
103 | 103 |
104 // Tests behavior with an empty input string. | 104 // Tests behavior with an empty input string. |
105 TEST(CommandLineTest, EmptyString) { | 105 TEST(CommandLineTest, EmptyString) { |
106 #if defined(OS_WIN) | 106 #if defined(OS_WIN) |
107 CommandLine cl = CommandLine::FromString(L""); | 107 CommandLine cl = CommandLine::FromString(L""); |
108 EXPECT_TRUE(cl.command_line_string().empty()); | 108 EXPECT_TRUE(cl.command_line_string().empty()); |
109 EXPECT_TRUE(cl.program().empty()); | 109 EXPECT_TRUE(cl.GetProgram().value().empty()); |
viettrungluu
2010/10/14 19:51:27
Or maybe even "GetProgram().empty()"?
| |
110 #elif defined(OS_POSIX) | 110 #elif defined(OS_POSIX) |
111 CommandLine cl(0, NULL); | 111 CommandLine cl(0, NULL); |
112 EXPECT_TRUE(cl.argv().size() == 0); | 112 EXPECT_TRUE(cl.argv().size() == 0); |
113 #endif | 113 #endif |
114 EXPECT_EQ(0U, cl.args().size()); | 114 EXPECT_EQ(0U, cl.args().size()); |
115 } | 115 } |
116 | 116 |
117 // Test methods for appending switches to a command line. | 117 // Test methods for appending switches to a command line. |
118 TEST(CommandLineTest, AppendSwitches) { | 118 TEST(CommandLineTest, AppendSwitches) { |
119 std::string switch1 = "switch1"; | 119 std::string switch1 = "switch1"; |
(...skipping 27 matching lines...) Expand all Loading... | |
147 #if defined(OS_WIN) | 147 #if defined(OS_WIN) |
148 EXPECT_EQ(L"\"Program\" " | 148 EXPECT_EQ(L"\"Program\" " |
149 L"--switch1 " | 149 L"--switch1 " |
150 L"--switch2=value " | 150 L"--switch2=value " |
151 L"--switch3=\"a value with spaces\" " | 151 L"--switch3=\"a value with spaces\" " |
152 L"--switch4=\"\\\"a value with quotes\\\"\" " | 152 L"--switch4=\"\\\"a value with quotes\\\"\" " |
153 L"--quotes=\"" TRICKY_QUOTED L"\"", | 153 L"--quotes=\"" TRICKY_QUOTED L"\"", |
154 cl.command_line_string()); | 154 cl.command_line_string()); |
155 #endif | 155 #endif |
156 } | 156 } |
OLD | NEW |