Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: base/command_line_unittest.cc

Issue 2778173003: base: Support command line wrappers with quoted arguments (Closed)
Patch Set: Review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/command_line.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/command_line.h" 5 #include "base/command_line.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 CommandLine copy_constructed(*initial); 399 CommandLine copy_constructed(*initial);
400 CommandLine assigned = *initial; 400 CommandLine assigned = *initial;
401 CommandLine::SwitchMap switch_map = initial->GetSwitches(); 401 CommandLine::SwitchMap switch_map = initial->GetSwitches();
402 initial.reset(); 402 initial.reset();
403 for (const auto& pair : switch_map) 403 for (const auto& pair : switch_map)
404 EXPECT_TRUE(copy_constructed.HasSwitch(pair.first)); 404 EXPECT_TRUE(copy_constructed.HasSwitch(pair.first));
405 for (const auto& pair : switch_map) 405 for (const auto& pair : switch_map)
406 EXPECT_TRUE(assigned.HasSwitch(pair.first)); 406 EXPECT_TRUE(assigned.HasSwitch(pair.first));
407 } 407 }
408 408
409 TEST(CommandLineTest, PrependSimpleWrapper) {
410 CommandLine cl(FilePath(FILE_PATH_LITERAL("Program")));
411 cl.AppendSwitch("a");
412 cl.AppendSwitch("b");
413 cl.PrependWrapper(FILE_PATH_LITERAL("wrapper --foo --bar"));
414
415 EXPECT_EQ(6u, cl.argv().size());
416 EXPECT_EQ(FILE_PATH_LITERAL("wrapper"), cl.argv()[0]);
417 EXPECT_EQ(FILE_PATH_LITERAL("--foo"), cl.argv()[1]);
418 EXPECT_EQ(FILE_PATH_LITERAL("--bar"), cl.argv()[2]);
419 EXPECT_EQ(FILE_PATH_LITERAL("Program"), cl.argv()[3]);
420 EXPECT_EQ(FILE_PATH_LITERAL("--a"), cl.argv()[4]);
421 EXPECT_EQ(FILE_PATH_LITERAL("--b"), cl.argv()[5]);
422 }
423
424 TEST(CommandLineTest, PrependComplexWrapper) {
425 CommandLine cl(FilePath(FILE_PATH_LITERAL("Program")));
426 cl.AppendSwitch("a");
427 cl.AppendSwitch("b");
428 cl.PrependWrapper(
429 FILE_PATH_LITERAL("wrapper --foo='hello world' --bar=\"let's go\""));
430
431 EXPECT_EQ(6u, cl.argv().size());
432 EXPECT_EQ(FILE_PATH_LITERAL("wrapper"), cl.argv()[0]);
433 EXPECT_EQ(FILE_PATH_LITERAL("--foo='hello world'"), cl.argv()[1]);
434 EXPECT_EQ(FILE_PATH_LITERAL("--bar=\"let's go\""), cl.argv()[2]);
435 EXPECT_EQ(FILE_PATH_LITERAL("Program"), cl.argv()[3]);
436 EXPECT_EQ(FILE_PATH_LITERAL("--a"), cl.argv()[4]);
437 EXPECT_EQ(FILE_PATH_LITERAL("--b"), cl.argv()[5]);
438 }
439
409 } // namespace base 440 } // namespace base
OLDNEW
« no previous file with comments | « base/command_line.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698