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

Side by Side Diff: base/command_line_unittest.cc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 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/callback_unittest.cc ('k') | base/containers/mru_cache_unittest.cc » ('j') | 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"
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
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
OLDNEW
« no previous file with comments | « base/callback_unittest.cc ('k') | base/containers/mru_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698