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 "base/command_line.h" |
| 6 |
| 7 #include <memory> |
5 #include <string> | 8 #include <string> |
6 #include <vector> | 9 #include <vector> |
7 | 10 |
8 #include "base/command_line.h" | |
9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 | 18 |
18 // To test Windows quoting behavior, we use a string that has some backslashes | 19 // To test Windows quoting behavior, we use a string that has some backslashes |
19 // and quotes. | 20 // and quotes. |
20 // Consider the command-line argument: q\"bs1\bs2\\bs3q\\\" | 21 // Consider the command-line argument: q\"bs1\bs2\\bs3q\\\" |
21 // Here it is with C-style escapes. | 22 // Here it is with C-style escapes. |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 // whether or not the test runner does so. | 384 // whether or not the test runner does so. |
384 CommandLine::Init(0, NULL); | 385 CommandLine::Init(0, NULL); |
385 CommandLine* initial = CommandLine::ForCurrentProcess(); | 386 CommandLine* initial = CommandLine::ForCurrentProcess(); |
386 EXPECT_FALSE(CommandLine::Init(0, NULL)); | 387 EXPECT_FALSE(CommandLine::Init(0, NULL)); |
387 CommandLine* current = CommandLine::ForCurrentProcess(); | 388 CommandLine* current = CommandLine::ForCurrentProcess(); |
388 EXPECT_EQ(initial, current); | 389 EXPECT_EQ(initial, current); |
389 } | 390 } |
390 | 391 |
391 // Test that copies of CommandLine have a valid StringPiece map. | 392 // Test that copies of CommandLine have a valid StringPiece map. |
392 TEST(CommandLineTest, Copy) { | 393 TEST(CommandLineTest, Copy) { |
393 scoped_ptr<CommandLine> initial(new CommandLine(CommandLine::NO_PROGRAM)); | 394 std::unique_ptr<CommandLine> initial( |
| 395 new CommandLine(CommandLine::NO_PROGRAM)); |
394 initial->AppendSwitch("a"); | 396 initial->AppendSwitch("a"); |
395 initial->AppendSwitch("bbbbbbbbbbbbbbb"); | 397 initial->AppendSwitch("bbbbbbbbbbbbbbb"); |
396 initial->AppendSwitch("c"); | 398 initial->AppendSwitch("c"); |
397 CommandLine copy_constructed(*initial); | 399 CommandLine copy_constructed(*initial); |
398 CommandLine assigned = *initial; | 400 CommandLine assigned = *initial; |
399 CommandLine::SwitchMap switch_map = initial->GetSwitches(); | 401 CommandLine::SwitchMap switch_map = initial->GetSwitches(); |
400 initial.reset(); | 402 initial.reset(); |
401 for (const auto& pair : switch_map) | 403 for (const auto& pair : switch_map) |
402 EXPECT_TRUE(copy_constructed.HasSwitch(pair.first)); | 404 EXPECT_TRUE(copy_constructed.HasSwitch(pair.first)); |
403 for (const auto& pair : switch_map) | 405 for (const auto& pair : switch_map) |
404 EXPECT_TRUE(assigned.HasSwitch(pair.first)); | 406 EXPECT_TRUE(assigned.HasSwitch(pair.first)); |
405 } | 407 } |
406 | 408 |
407 } // namespace base | 409 } // namespace base |
OLD | NEW |