OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 EXPECT_FALSE(cl.HasSwitch("dog")); | 54 EXPECT_FALSE(cl.HasSwitch("dog")); |
55 EXPECT_FALSE(cl.HasSwitch("cat")); | 55 EXPECT_FALSE(cl.HasSwitch("cat")); |
56 EXPECT_FALSE(cl.HasSwitch("output-rotation")); | 56 EXPECT_FALSE(cl.HasSwitch("output-rotation")); |
57 EXPECT_FALSE(cl.HasSwitch("not-a-switch")); | 57 EXPECT_FALSE(cl.HasSwitch("not-a-switch")); |
58 EXPECT_FALSE(cl.HasSwitch("--")); | 58 EXPECT_FALSE(cl.HasSwitch("--")); |
59 | 59 |
60 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("program")).value(), | 60 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("program")).value(), |
61 cl.GetProgram().value()); | 61 cl.GetProgram().value()); |
62 | 62 |
63 EXPECT_TRUE(cl.HasSwitch("foo")); | 63 EXPECT_TRUE(cl.HasSwitch("foo")); |
64 #if defined(OS_WIN) | |
65 EXPECT_TRUE(cl.HasSwitch("bar")); | |
66 #else | |
67 EXPECT_FALSE(cl.HasSwitch("bar")); | 64 EXPECT_FALSE(cl.HasSwitch("bar")); |
68 #endif | |
69 EXPECT_TRUE(cl.HasSwitch("baz")); | 65 EXPECT_TRUE(cl.HasSwitch("baz")); |
70 EXPECT_TRUE(cl.HasSwitch("spaetzle")); | 66 EXPECT_TRUE(cl.HasSwitch("spaetzle")); |
71 EXPECT_TRUE(cl.HasSwitch("other-switches")); | 67 EXPECT_TRUE(cl.HasSwitch("other-switches")); |
72 EXPECT_TRUE(cl.HasSwitch("input-translation")); | 68 EXPECT_TRUE(cl.HasSwitch("input-translation")); |
73 | 69 |
74 EXPECT_EQ("Crepe", cl.GetSwitchValueASCII("spaetzle")); | 70 EXPECT_EQ("Crepe", cl.GetSwitchValueASCII("spaetzle")); |
75 EXPECT_EQ("", cl.GetSwitchValueASCII("foo")); | 71 EXPECT_EQ("", cl.GetSwitchValueASCII("foo")); |
76 EXPECT_EQ("", cl.GetSwitchValueASCII("bar")); | 72 EXPECT_EQ("", cl.GetSwitchValueASCII("bar")); |
77 EXPECT_EQ("", cl.GetSwitchValueASCII("cruller")); | 73 EXPECT_EQ("", cl.GetSwitchValueASCII("cruller")); |
78 EXPECT_EQ("--dog=canine --cat=feline", cl.GetSwitchValueASCII( | 74 EXPECT_EQ("--dog=canine --cat=feline", cl.GetSwitchValueASCII( |
(...skipping 16 matching lines...) Expand all Loading... |
95 ++iter; | 91 ++iter; |
96 EXPECT_EQ(FILE_PATH_LITERAL("--not-a-switch"), *iter); | 92 EXPECT_EQ(FILE_PATH_LITERAL("--not-a-switch"), *iter); |
97 ++iter; | 93 ++iter; |
98 EXPECT_EQ(FILE_PATH_LITERAL("\"in the time of submarines...\""), *iter); | 94 EXPECT_EQ(FILE_PATH_LITERAL("\"in the time of submarines...\""), *iter); |
99 ++iter; | 95 ++iter; |
100 EXPECT_EQ(FILE_PATH_LITERAL("unquoted arg-with-space"), *iter); | 96 EXPECT_EQ(FILE_PATH_LITERAL("unquoted arg-with-space"), *iter); |
101 ++iter; | 97 ++iter; |
102 EXPECT_TRUE(iter == args.end()); | 98 EXPECT_TRUE(iter == args.end()); |
103 } | 99 } |
104 | 100 |
105 TEST(CommandLineTest, CommandLineFromString) { | |
106 #if defined(OS_WIN) | |
107 CommandLine cl = CommandLine::FromString( | |
108 L"program --foo= -bAr /Spaetzel=pierogi /Baz flim " | |
109 L"--other-switches=\"--dog=canine --cat=feline\" " | |
110 L"-spaetzle=Crepe -=loosevalue FLAN " | |
111 L"--input-translation=\"45\"--output-rotation " | |
112 L"--quotes=" + kTrickyQuoted + L" " | |
113 L"-- -- --not-a-switch " | |
114 L"\"in the time of submarines...\""); | |
115 | |
116 EXPECT_FALSE(cl.GetCommandLineString().empty()); | |
117 EXPECT_FALSE(cl.HasSwitch("cruller")); | |
118 EXPECT_FALSE(cl.HasSwitch("flim")); | |
119 EXPECT_FALSE(cl.HasSwitch("program")); | |
120 EXPECT_FALSE(cl.HasSwitch("dog")); | |
121 EXPECT_FALSE(cl.HasSwitch("cat")); | |
122 EXPECT_FALSE(cl.HasSwitch("output-rotation")); | |
123 EXPECT_FALSE(cl.HasSwitch("not-a-switch")); | |
124 EXPECT_FALSE(cl.HasSwitch("--")); | |
125 | |
126 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("program")).value(), | |
127 cl.GetProgram().value()); | |
128 | |
129 EXPECT_TRUE(cl.HasSwitch("foo")); | |
130 EXPECT_TRUE(cl.HasSwitch("bar")); | |
131 EXPECT_TRUE(cl.HasSwitch("baz")); | |
132 EXPECT_TRUE(cl.HasSwitch("spaetzle")); | |
133 EXPECT_TRUE(cl.HasSwitch("other-switches")); | |
134 EXPECT_TRUE(cl.HasSwitch("input-translation")); | |
135 EXPECT_TRUE(cl.HasSwitch("quotes")); | |
136 | |
137 EXPECT_EQ("Crepe", cl.GetSwitchValueASCII("spaetzle")); | |
138 EXPECT_EQ("", cl.GetSwitchValueASCII("foo")); | |
139 EXPECT_EQ("", cl.GetSwitchValueASCII("bar")); | |
140 EXPECT_EQ("", cl.GetSwitchValueASCII("cruller")); | |
141 EXPECT_EQ("--dog=canine --cat=feline", cl.GetSwitchValueASCII( | |
142 "other-switches")); | |
143 EXPECT_EQ("45--output-rotation", cl.GetSwitchValueASCII("input-translation")); | |
144 EXPECT_EQ(kTricky, cl.GetSwitchValueNative("quotes")); | |
145 | |
146 const CommandLine::StringVector& args = cl.GetArgs(); | |
147 ASSERT_EQ(5U, args.size()); | |
148 | |
149 std::vector<CommandLine::StringType>::const_iterator iter = args.begin(); | |
150 EXPECT_EQ(FILE_PATH_LITERAL("flim"), *iter); | |
151 ++iter; | |
152 EXPECT_EQ(FILE_PATH_LITERAL("FLAN"), *iter); | |
153 ++iter; | |
154 EXPECT_EQ(FILE_PATH_LITERAL("--"), *iter); | |
155 ++iter; | |
156 EXPECT_EQ(FILE_PATH_LITERAL("--not-a-switch"), *iter); | |
157 ++iter; | |
158 EXPECT_EQ(FILE_PATH_LITERAL("in the time of submarines..."), *iter); | |
159 ++iter; | |
160 EXPECT_TRUE(iter == args.end()); | |
161 | |
162 // Check that a generated string produces an equivalent command line. | |
163 CommandLine cl_duplicate = CommandLine::FromString(cl.GetCommandLineString()); | |
164 EXPECT_EQ(cl.GetCommandLineString(), cl_duplicate.GetCommandLineString()); | |
165 #endif | |
166 } | |
167 | |
168 // Tests behavior with an empty input string. | 101 // Tests behavior with an empty input string. |
169 TEST(CommandLineTest, EmptyString) { | 102 TEST(CommandLineTest, EmptyString) { |
170 #if defined(OS_WIN) | |
171 CommandLine cl_from_string = CommandLine::FromString(L""); | |
172 EXPECT_TRUE(cl_from_string.GetCommandLineString().empty()); | |
173 EXPECT_TRUE(cl_from_string.GetProgram().empty()); | |
174 EXPECT_EQ(1U, cl_from_string.argv().size()); | |
175 EXPECT_TRUE(cl_from_string.GetArgs().empty()); | |
176 #endif | |
177 CommandLine cl_from_argv(0, NULL); | 103 CommandLine cl_from_argv(0, NULL); |
178 EXPECT_TRUE(cl_from_argv.GetCommandLineString().empty()); | 104 EXPECT_TRUE(cl_from_argv.GetCommandLineString().empty()); |
179 EXPECT_TRUE(cl_from_argv.GetProgram().empty()); | 105 EXPECT_TRUE(cl_from_argv.GetProgram().empty()); |
180 EXPECT_EQ(1U, cl_from_argv.argv().size()); | 106 EXPECT_EQ(1U, cl_from_argv.argv().size()); |
181 EXPECT_TRUE(cl_from_argv.GetArgs().empty()); | 107 EXPECT_TRUE(cl_from_argv.GetArgs().empty()); |
182 } | 108 } |
183 | 109 |
184 TEST(CommandLineTest, GetArgumentsString) { | 110 TEST(CommandLineTest, GetArgumentsString) { |
185 static const FilePath::CharType kPath1[] = | 111 static const FilePath::CharType kPath1[] = |
186 FILE_PATH_LITERAL("C:\\Some File\\With Spaces.ggg"); | 112 FILE_PATH_LITERAL("C:\\Some File\\With Spaces.ggg"); |
187 static const FilePath::CharType kPath2[] = | 113 static const FilePath::CharType kPath2[] = |
188 FILE_PATH_LITERAL("C:\\no\\spaces.ggg"); | 114 FILE_PATH_LITERAL("C:\\no\\spaces.ggg"); |
189 | 115 |
190 static const char kFirstArgName[] = "first-arg"; | 116 static const char kFirstArgName[] = "first-arg"; |
191 static const char kSecondArgName[] = "arg2"; | 117 static const char kSecondArgName[] = "arg2"; |
192 static const char kThirdArgName[] = "arg with space"; | 118 static const char kThirdArgName[] = "arg with space"; |
193 static const char kFourthArgName[] = "nospace"; | 119 static const char kFourthArgName[] = "nospace"; |
194 static const char kFifthArgName[] = "%1"; | 120 static const char kFifthArgName[] = "%1"; |
195 | 121 |
196 CommandLine cl(CommandLine::NO_PROGRAM); | 122 CommandLine cl(CommandLine::NO_PROGRAM); |
197 cl.AppendSwitchPath(kFirstArgName, FilePath(kPath1)); | 123 cl.AppendSwitchPath(kFirstArgName, FilePath(kPath1)); |
198 cl.AppendSwitchPath(kSecondArgName, FilePath(kPath2)); | 124 cl.AppendSwitchPath(kSecondArgName, FilePath(kPath2)); |
199 cl.AppendArg(kThirdArgName); | 125 cl.AppendArg(kThirdArgName); |
200 cl.AppendArg(kFourthArgName); | 126 cl.AppendArg(kFourthArgName); |
201 cl.AppendArg(kFifthArgName); | 127 cl.AppendArg(kFifthArgName); |
202 | 128 |
203 #if defined(OS_WIN) | |
204 CommandLine::StringType expected_first_arg(UTF8ToUTF16(kFirstArgName)); | |
205 CommandLine::StringType expected_second_arg(UTF8ToUTF16(kSecondArgName)); | |
206 CommandLine::StringType expected_third_arg(UTF8ToUTF16(kThirdArgName)); | |
207 CommandLine::StringType expected_fourth_arg(UTF8ToUTF16(kFourthArgName)); | |
208 CommandLine::StringType expected_fifth_arg(UTF8ToUTF16(kFifthArgName)); | |
209 #elif defined(OS_POSIX) | |
210 CommandLine::StringType expected_first_arg(kFirstArgName); | 129 CommandLine::StringType expected_first_arg(kFirstArgName); |
211 CommandLine::StringType expected_second_arg(kSecondArgName); | 130 CommandLine::StringType expected_second_arg(kSecondArgName); |
212 CommandLine::StringType expected_third_arg(kThirdArgName); | 131 CommandLine::StringType expected_third_arg(kThirdArgName); |
213 CommandLine::StringType expected_fourth_arg(kFourthArgName); | 132 CommandLine::StringType expected_fourth_arg(kFourthArgName); |
214 CommandLine::StringType expected_fifth_arg(kFifthArgName); | 133 CommandLine::StringType expected_fifth_arg(kFifthArgName); |
215 #endif | |
216 | 134 |
217 #if defined(OS_WIN) | |
218 #define QUOTE_ON_WIN FILE_PATH_LITERAL("\"") | |
219 #else | |
220 #define QUOTE_ON_WIN FILE_PATH_LITERAL("") | 135 #define QUOTE_ON_WIN FILE_PATH_LITERAL("") |
221 #endif // OS_WIN | |
222 | 136 |
223 CommandLine::StringType expected_str; | 137 CommandLine::StringType expected_str; |
224 expected_str.append(FILE_PATH_LITERAL("--")) | 138 expected_str.append(FILE_PATH_LITERAL("--")) |
225 .append(expected_first_arg) | 139 .append(expected_first_arg) |
226 .append(FILE_PATH_LITERAL("=")) | 140 .append(FILE_PATH_LITERAL("=")) |
227 .append(QUOTE_ON_WIN) | 141 .append(QUOTE_ON_WIN) |
228 .append(kPath1) | 142 .append(kPath1) |
229 .append(QUOTE_ON_WIN) | 143 .append(QUOTE_ON_WIN) |
230 .append(FILE_PATH_LITERAL(" ")) | 144 .append(FILE_PATH_LITERAL(" ")) |
231 .append(FILE_PATH_LITERAL("--")) | 145 .append(FILE_PATH_LITERAL("--")) |
232 .append(expected_second_arg) | 146 .append(expected_second_arg) |
233 .append(FILE_PATH_LITERAL("=")) | 147 .append(FILE_PATH_LITERAL("=")) |
234 .append(QUOTE_ON_WIN) | 148 .append(QUOTE_ON_WIN) |
235 .append(kPath2) | 149 .append(kPath2) |
236 .append(QUOTE_ON_WIN) | 150 .append(QUOTE_ON_WIN) |
237 .append(FILE_PATH_LITERAL(" ")) | 151 .append(FILE_PATH_LITERAL(" ")) |
238 .append(QUOTE_ON_WIN) | 152 .append(QUOTE_ON_WIN) |
239 .append(expected_third_arg) | 153 .append(expected_third_arg) |
240 .append(QUOTE_ON_WIN) | 154 .append(QUOTE_ON_WIN) |
241 .append(FILE_PATH_LITERAL(" ")) | 155 .append(FILE_PATH_LITERAL(" ")) |
242 .append(expected_fourth_arg) | 156 .append(expected_fourth_arg) |
243 .append(FILE_PATH_LITERAL(" ")); | 157 .append(FILE_PATH_LITERAL(" ")); |
244 | 158 |
245 CommandLine::StringType expected_str_no_quote_placeholders(expected_str); | 159 CommandLine::StringType expected_str_no_quote_placeholders(expected_str); |
246 expected_str_no_quote_placeholders.append(expected_fifth_arg); | 160 expected_str_no_quote_placeholders.append(expected_fifth_arg); |
247 EXPECT_EQ(expected_str_no_quote_placeholders, cl.GetArgumentsString()); | 161 EXPECT_EQ(expected_str_no_quote_placeholders, cl.GetArgumentsString()); |
248 | 162 |
249 #if defined(OS_WIN) | |
250 CommandLine::StringType expected_str_quote_placeholders(expected_str); | |
251 expected_str_quote_placeholders.append(QUOTE_ON_WIN) | |
252 .append(expected_fifth_arg) | |
253 .append(QUOTE_ON_WIN); | |
254 EXPECT_EQ(expected_str_quote_placeholders, | |
255 cl.GetArgumentsStringWithPlaceholders()); | |
256 #endif | |
257 } | 163 } |
258 | 164 |
259 // Test methods for appending switches to a command line. | 165 // Test methods for appending switches to a command line. |
260 TEST(CommandLineTest, AppendSwitches) { | 166 TEST(CommandLineTest, AppendSwitches) { |
261 std::string switch1 = "switch1"; | 167 std::string switch1 = "switch1"; |
262 std::string switch2 = "switch2"; | 168 std::string switch2 = "switch2"; |
263 std::string value2 = "value"; | 169 std::string value2 = "value"; |
264 std::string switch3 = "switch3"; | 170 std::string switch3 = "switch3"; |
265 std::string value3 = "a value with spaces"; | 171 std::string value3 = "a value with spaces"; |
266 std::string switch4 = "switch4"; | 172 std::string switch4 = "switch4"; |
(...skipping 13 matching lines...) Expand all Loading... |
280 EXPECT_TRUE(cl.HasSwitch(switch1)); | 186 EXPECT_TRUE(cl.HasSwitch(switch1)); |
281 EXPECT_TRUE(cl.HasSwitch(switch2)); | 187 EXPECT_TRUE(cl.HasSwitch(switch2)); |
282 EXPECT_EQ(value2, cl.GetSwitchValueASCII(switch2)); | 188 EXPECT_EQ(value2, cl.GetSwitchValueASCII(switch2)); |
283 EXPECT_TRUE(cl.HasSwitch(switch3)); | 189 EXPECT_TRUE(cl.HasSwitch(switch3)); |
284 EXPECT_EQ(value3, cl.GetSwitchValueASCII(switch3)); | 190 EXPECT_EQ(value3, cl.GetSwitchValueASCII(switch3)); |
285 EXPECT_TRUE(cl.HasSwitch(switch4)); | 191 EXPECT_TRUE(cl.HasSwitch(switch4)); |
286 EXPECT_EQ(value4, cl.GetSwitchValueASCII(switch4)); | 192 EXPECT_EQ(value4, cl.GetSwitchValueASCII(switch4)); |
287 EXPECT_TRUE(cl.HasSwitch(switch5)); | 193 EXPECT_TRUE(cl.HasSwitch(switch5)); |
288 EXPECT_EQ(value5, cl.GetSwitchValueNative(switch5)); | 194 EXPECT_EQ(value5, cl.GetSwitchValueNative(switch5)); |
289 | 195 |
290 #if defined(OS_WIN) | |
291 EXPECT_EQ(L"Program " | |
292 L"--switch1 " | |
293 L"--switch2=value " | |
294 L"--switch3=\"a value with spaces\" " | |
295 L"--switch4=\"\\\"a value with quotes\\\"\" " | |
296 // Even though the switches are unique, appending can add repeat | |
297 // switches to argv. | |
298 L"--quotes=\"\\\"a value with quotes\\\"\" " | |
299 L"--quotes=\"" + kTrickyQuoted + L"\"", | |
300 cl.GetCommandLineString()); | |
301 #endif | |
302 } | 196 } |
303 | 197 |
304 TEST(CommandLineTest, AppendSwitchesDashDash) { | 198 TEST(CommandLineTest, AppendSwitchesDashDash) { |
305 const CommandLine::CharType* raw_argv[] = { FILE_PATH_LITERAL("prog"), | 199 const CommandLine::CharType* raw_argv[] = { FILE_PATH_LITERAL("prog"), |
306 FILE_PATH_LITERAL("--"), | 200 FILE_PATH_LITERAL("--"), |
307 FILE_PATH_LITERAL("--arg1") }; | 201 FILE_PATH_LITERAL("--arg1") }; |
308 CommandLine cl(arraysize(raw_argv), raw_argv); | 202 CommandLine cl(arraysize(raw_argv), raw_argv); |
309 | 203 |
310 cl.AppendSwitch("switch1"); | 204 cl.AppendSwitch("switch1"); |
311 cl.AppendSwitchASCII("switch2", "foo"); | 205 cl.AppendSwitchASCII("switch2", "foo"); |
(...skipping 28 matching lines...) Expand all Loading... |
340 c1.AppendSwitch("switch1"); | 234 c1.AppendSwitch("switch1"); |
341 CommandLine c2(FilePath(FILE_PATH_LITERAL("Program2"))); | 235 CommandLine c2(FilePath(FILE_PATH_LITERAL("Program2"))); |
342 c2.AppendSwitch("switch2"); | 236 c2.AppendSwitch("switch2"); |
343 | 237 |
344 c1.AppendArguments(c2, true); | 238 c1.AppendArguments(c2, true); |
345 EXPECT_EQ(c1.GetProgram().value(), c2.GetProgram().value()); | 239 EXPECT_EQ(c1.GetProgram().value(), c2.GetProgram().value()); |
346 EXPECT_TRUE(c1.HasSwitch("switch1")); | 240 EXPECT_TRUE(c1.HasSwitch("switch1")); |
347 EXPECT_TRUE(c1.HasSwitch("switch2")); | 241 EXPECT_TRUE(c1.HasSwitch("switch2")); |
348 } | 242 } |
349 | 243 |
350 #if defined(OS_WIN) | |
351 // Make sure that the command line string program paths are quoted as necessary. | |
352 // This only makes sense on Windows and the test is basically here to guard | |
353 // against regressions. | |
354 TEST(CommandLineTest, ProgramQuotes) { | |
355 // Check that quotes are not added for paths without spaces. | |
356 const FilePath kProgram(L"Program"); | |
357 CommandLine cl_program(kProgram); | |
358 EXPECT_EQ(kProgram.value(), cl_program.GetProgram().value()); | |
359 EXPECT_EQ(kProgram.value(), cl_program.GetCommandLineString()); | |
360 | |
361 const FilePath kProgramPath(L"Program Path"); | |
362 | |
363 // Check that quotes are not returned from GetProgram(). | |
364 CommandLine cl_program_path(kProgramPath); | |
365 EXPECT_EQ(kProgramPath.value(), cl_program_path.GetProgram().value()); | |
366 | |
367 // Check that quotes are added to command line string paths containing spaces. | |
368 CommandLine::StringType cmd_string(cl_program_path.GetCommandLineString()); | |
369 EXPECT_EQ(L"\"Program Path\"", cmd_string); | |
370 | |
371 // Check the optional quoting of placeholders in programs. | |
372 CommandLine cl_quote_placeholder(FilePath(L"%1")); | |
373 EXPECT_EQ(L"%1", cl_quote_placeholder.GetCommandLineString()); | |
374 EXPECT_EQ(L"\"%1\"", | |
375 cl_quote_placeholder.GetCommandLineStringWithPlaceholders()); | |
376 } | |
377 #endif | |
378 | |
379 // Calling Init multiple times should not modify the previous CommandLine. | 244 // Calling Init multiple times should not modify the previous CommandLine. |
380 TEST(CommandLineTest, Init) { | 245 TEST(CommandLineTest, Init) { |
381 CommandLine* initial = CommandLine::ForCurrentProcess(); | 246 CommandLine* initial = CommandLine::ForCurrentProcess(); |
382 EXPECT_FALSE(CommandLine::Init(0, NULL)); | 247 EXPECT_FALSE(CommandLine::Init(0, NULL)); |
383 CommandLine* current = CommandLine::ForCurrentProcess(); | 248 CommandLine* current = CommandLine::ForCurrentProcess(); |
384 EXPECT_EQ(initial, current); | 249 EXPECT_EQ(initial, current); |
385 } | 250 } |
386 | 251 |
387 // Test that copies of CommandLine have a valid StringPiece map. | 252 // Test that copies of CommandLine have a valid StringPiece map. |
388 TEST(CommandLineTest, Copy) { | 253 TEST(CommandLineTest, Copy) { |
389 scoped_ptr<CommandLine> initial(new CommandLine(CommandLine::NO_PROGRAM)); | 254 scoped_ptr<CommandLine> initial(new CommandLine(CommandLine::NO_PROGRAM)); |
390 initial->AppendSwitch("a"); | 255 initial->AppendSwitch("a"); |
391 initial->AppendSwitch("bbbbbbbbbbbbbbb"); | 256 initial->AppendSwitch("bbbbbbbbbbbbbbb"); |
392 initial->AppendSwitch("c"); | 257 initial->AppendSwitch("c"); |
393 CommandLine copy_constructed(*initial); | 258 CommandLine copy_constructed(*initial); |
394 CommandLine assigned = *initial; | 259 CommandLine assigned = *initial; |
395 CommandLine::SwitchMap switch_map = initial->GetSwitches(); | 260 CommandLine::SwitchMap switch_map = initial->GetSwitches(); |
396 initial.reset(); | 261 initial.reset(); |
397 for (const auto& pair : switch_map) | 262 for (const auto& pair : switch_map) |
398 EXPECT_TRUE(copy_constructed.HasSwitch(pair.first)); | 263 EXPECT_TRUE(copy_constructed.HasSwitch(pair.first)); |
399 for (const auto& pair : switch_map) | 264 for (const auto& pair : switch_map) |
400 EXPECT_TRUE(assigned.HasSwitch(pair.first)); | 265 EXPECT_TRUE(assigned.HasSwitch(pair.first)); |
401 } | 266 } |
402 | 267 |
403 } // namespace base | 268 } // namespace base |
OLD | NEW |