OLD | NEW |
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/basictypes.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 | 103 |
104 // Tests behavior with an empty input string. | 104 // Tests behavior with an empty input string. |
105 TEST(CommandLineTest, EmptyString) { | 105 TEST(CommandLineTest, EmptyString) { |
106 #if defined(OS_WIN) | 106 #if defined(OS_WIN) |
107 CommandLine cl = CommandLine::FromString(L""); | 107 CommandLine cl = CommandLine::FromString(L""); |
108 EXPECT_TRUE(cl.command_line_string().empty()); | 108 EXPECT_TRUE(cl.command_line_string().empty()); |
109 EXPECT_TRUE(cl.GetProgram().empty()); | 109 EXPECT_TRUE(cl.GetProgram().empty()); |
110 #elif defined(OS_POSIX) | 110 #elif defined(OS_POSIX) |
111 CommandLine cl(0, NULL); | 111 CommandLine cl(0, NULL); |
112 EXPECT_EQ(0U, cl.argv().size()); | 112 EXPECT_TRUE(cl.argv().empty()); |
113 #endif | 113 #endif |
114 EXPECT_EQ(0U, cl.args().size()); | 114 EXPECT_TRUE(cl.args().empty()); |
115 } | 115 } |
116 | 116 |
117 // Test methods for appending switches to a command line. | 117 // Test methods for appending switches to a command line. |
118 TEST(CommandLineTest, AppendSwitches) { | 118 TEST(CommandLineTest, AppendSwitches) { |
119 std::string switch1 = "switch1"; | 119 std::string switch1 = "switch1"; |
120 std::string switch2 = "switch2"; | 120 std::string switch2 = "switch2"; |
121 std::string value = "value"; | 121 std::string value = "value"; |
122 std::string switch3 = "switch3"; | 122 std::string switch3 = "switch3"; |
123 std::string value3 = "a value with spaces"; | 123 std::string value3 = "a value with spaces"; |
124 std::string switch4 = "switch4"; | 124 std::string switch4 = "switch4"; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 EXPECT_EQ(kProgram.value(), cl.GetProgram().value()); | 191 EXPECT_EQ(kProgram.value(), cl.GetProgram().value()); |
192 | 192 |
193 // Verify that in the command line string, the program part is always quoted. | 193 // Verify that in the command line string, the program part is always quoted. |
194 CommandLine::StringType cmd(cl.command_line_string()); | 194 CommandLine::StringType cmd(cl.command_line_string()); |
195 CommandLine::StringType program(cl.GetProgram().value()); | 195 CommandLine::StringType program(cl.GetProgram().value()); |
196 EXPECT_EQ('"', cmd[0]); | 196 EXPECT_EQ('"', cmd[0]); |
197 EXPECT_EQ(program, cmd.substr(1, program.length())); | 197 EXPECT_EQ(program, cmd.substr(1, program.length())); |
198 EXPECT_EQ('"', cmd[program.length() + 1]); | 198 EXPECT_EQ('"', cmd[program.length() + 1]); |
199 } | 199 } |
200 #endif | 200 #endif |
OLD | NEW |