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

Side by Side Diff: base/command_line_unittest.cc

Issue 4928002: Changing the installer switches from wchar_t[] to char[].... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « base/command_line.cc ('k') | chrome/browser/browser_main_win.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/command_line.h" 9 #include "base/command_line.h"
9 #include "base/basictypes.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 // To test Windows quoting behavior, we use a string that has some backslashes 14 // To test Windows quoting behavior, we use a string that has some backslashes
15 // and quotes. 15 // and quotes.
16 // Consider the command-line argument: q\"bs1\bs2\\bs3q\\\" 16 // Consider the command-line argument: q\"bs1\bs2\\bs3q\\\"
17 // Here it is with C-style escapes. 17 // Here it is with C-style escapes.
18 #define TRICKY_QUOTED L"q\\\"bs1\\bs2\\\\bs3q\\\\\\\"" 18 #define TRICKY_QUOTED L"q\\\"bs1\\bs2\\\\bs3q\\\\\\\""
19 // It should be parsed by Windows as: q"bs1\bs2\\bs3q\" 19 // It should be parsed by Windows as: q"bs1\bs2\\bs3q\"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 #if defined(OS_WIN) 147 #if defined(OS_WIN)
148 EXPECT_EQ(L"\"Program\" " 148 EXPECT_EQ(L"\"Program\" "
149 L"--switch1 " 149 L"--switch1 "
150 L"--switch2=value " 150 L"--switch2=value "
151 L"--switch3=\"a value with spaces\" " 151 L"--switch3=\"a value with spaces\" "
152 L"--switch4=\"\\\"a value with quotes\\\"\" " 152 L"--switch4=\"\\\"a value with quotes\\\"\" "
153 L"--quotes=\"" TRICKY_QUOTED L"\"", 153 L"--quotes=\"" TRICKY_QUOTED L"\"",
154 cl.command_line_string()); 154 cl.command_line_string());
155 #endif 155 #endif
156 } 156 }
157
158 // Tests that when AppendArguments is called that the program is set correctly
159 // on the target CommandLine object and the switches from the source
160 // CommandLine are added to the target.
161 TEST(CommandLineTest, AppendArguments) {
162 CommandLine cl1(FilePath(FILE_PATH_LITERAL("Program")));
163 cl1.AppendSwitch("switch1");
164 cl1.AppendSwitchASCII("switch2", "foo");
165
166 CommandLine cl2(CommandLine::NO_PROGRAM);
167 cl2.AppendArguments(cl1, true);
168 EXPECT_EQ(cl1.GetProgram().value(), cl2.GetProgram().value());
169 EXPECT_EQ(cl1.command_line_string(), cl2.command_line_string());
170
171 CommandLine c1(FilePath(FILE_PATH_LITERAL("Program1")));
172 c1.AppendSwitch("switch1");
173 CommandLine c2(FilePath(FILE_PATH_LITERAL("Program2")));
174 c2.AppendSwitch("switch2");
175
176 c1.AppendArguments(c2, true);
177 EXPECT_EQ(c1.GetProgram().value(), c2.GetProgram().value());
178 EXPECT_TRUE(c1.HasSwitch("switch1"));
179 EXPECT_TRUE(c1.HasSwitch("switch2"));
180 }
181
OLDNEW
« no previous file with comments | « base/command_line.cc ('k') | chrome/browser/browser_main_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698