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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // Check the optional quoting of placeholders in programs. | 371 // Check the optional quoting of placeholders in programs. |
372 CommandLine cl_quote_placeholder(FilePath(L"%1")); | 372 CommandLine cl_quote_placeholder(FilePath(L"%1")); |
373 EXPECT_EQ(L"%1", cl_quote_placeholder.GetCommandLineString()); | 373 EXPECT_EQ(L"%1", cl_quote_placeholder.GetCommandLineString()); |
374 EXPECT_EQ(L"\"%1\"", | 374 EXPECT_EQ(L"\"%1\"", |
375 cl_quote_placeholder.GetCommandLineStringWithPlaceholders()); | 375 cl_quote_placeholder.GetCommandLineStringWithPlaceholders()); |
376 } | 376 } |
377 #endif | 377 #endif |
378 | 378 |
379 // Calling Init multiple times should not modify the previous CommandLine. | 379 // Calling Init multiple times should not modify the previous CommandLine. |
380 TEST(CommandLineTest, Init) { | 380 TEST(CommandLineTest, Init) { |
| 381 // Call Init without checking output once so we know it's been called |
| 382 // whether or not the test runner does so. |
| 383 CommandLine::Init(0, NULL); |
381 CommandLine* initial = CommandLine::ForCurrentProcess(); | 384 CommandLine* initial = CommandLine::ForCurrentProcess(); |
382 EXPECT_FALSE(CommandLine::Init(0, NULL)); | 385 EXPECT_FALSE(CommandLine::Init(0, NULL)); |
383 CommandLine* current = CommandLine::ForCurrentProcess(); | 386 CommandLine* current = CommandLine::ForCurrentProcess(); |
384 EXPECT_EQ(initial, current); | 387 EXPECT_EQ(initial, current); |
385 } | 388 } |
386 | 389 |
387 // Test that copies of CommandLine have a valid StringPiece map. | 390 // Test that copies of CommandLine have a valid StringPiece map. |
388 TEST(CommandLineTest, Copy) { | 391 TEST(CommandLineTest, Copy) { |
389 scoped_ptr<CommandLine> initial(new CommandLine(CommandLine::NO_PROGRAM)); | 392 scoped_ptr<CommandLine> initial(new CommandLine(CommandLine::NO_PROGRAM)); |
390 initial->AppendSwitch("a"); | 393 initial->AppendSwitch("a"); |
391 initial->AppendSwitch("bbbbbbbbbbbbbbb"); | 394 initial->AppendSwitch("bbbbbbbbbbbbbbb"); |
392 initial->AppendSwitch("c"); | 395 initial->AppendSwitch("c"); |
393 CommandLine copy_constructed(*initial); | 396 CommandLine copy_constructed(*initial); |
394 CommandLine assigned = *initial; | 397 CommandLine assigned = *initial; |
395 CommandLine::SwitchMap switch_map = initial->GetSwitches(); | 398 CommandLine::SwitchMap switch_map = initial->GetSwitches(); |
396 initial.reset(); | 399 initial.reset(); |
397 for (const auto& pair : switch_map) | 400 for (const auto& pair : switch_map) |
398 EXPECT_TRUE(copy_constructed.HasSwitch(pair.first)); | 401 EXPECT_TRUE(copy_constructed.HasSwitch(pair.first)); |
399 for (const auto& pair : switch_map) | 402 for (const auto& pair : switch_map) |
400 EXPECT_TRUE(assigned.HasSwitch(pair.first)); | 403 EXPECT_TRUE(assigned.HasSwitch(pair.first)); |
401 } | 404 } |
402 | 405 |
403 } // namespace base | 406 } // namespace base |
OLD | NEW |