OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 CommandLine cl(0, NULL); | 94 CommandLine cl(0, NULL); |
95 EXPECT_TRUE(cl.argv().size() == 0); | 95 EXPECT_TRUE(cl.argv().size() == 0); |
96 #endif | 96 #endif |
97 EXPECT_EQ(0U, cl.args().size()); | 97 EXPECT_EQ(0U, cl.args().size()); |
98 } | 98 } |
99 | 99 |
100 // Test methods for appending switches to a command line. | 100 // Test methods for appending switches to a command line. |
101 TEST(CommandLineTest, AppendSwitches) { | 101 TEST(CommandLineTest, AppendSwitches) { |
102 std::string switch1 = "switch1"; | 102 std::string switch1 = "switch1"; |
103 std::string switch2 = "switch2"; | 103 std::string switch2 = "switch2"; |
104 std::wstring value = L"value"; | 104 std::string value = "value"; |
105 std::string switch3 = "switch3"; | 105 std::string switch3 = "switch3"; |
106 std::wstring value3 = L"a value with spaces"; | 106 std::string value3 = "a value with spaces"; |
107 std::string switch4 = "switch4"; | 107 std::string switch4 = "switch4"; |
108 std::wstring value4 = L"\"a value with quotes\""; | 108 std::string value4 = "\"a value with quotes\""; |
109 | 109 |
110 CommandLine cl(FilePath(FILE_PATH_LITERAL("Program"))); | 110 CommandLine cl(FilePath(FILE_PATH_LITERAL("Program"))); |
111 | 111 |
112 cl.AppendSwitch(switch1); | 112 cl.AppendSwitch(switch1); |
113 cl.AppendSwitchWithValue(switch2, value); | 113 cl.AppendSwitchASCII(switch2, value); |
114 cl.AppendSwitchWithValue(switch3, value3); | 114 cl.AppendSwitchASCII(switch3, value3); |
115 cl.AppendSwitchWithValue(switch4, value4); | 115 cl.AppendSwitchASCII(switch4, value4); |
116 | 116 |
117 EXPECT_TRUE(cl.HasSwitch(switch1)); | 117 EXPECT_TRUE(cl.HasSwitch(switch1)); |
118 EXPECT_TRUE(cl.HasSwitch(switch2)); | 118 EXPECT_TRUE(cl.HasSwitch(switch2)); |
119 EXPECT_EQ(value, cl.GetSwitchValue(switch2)); | 119 EXPECT_EQ(value, cl.GetSwitchValue(switch2)); |
120 EXPECT_TRUE(cl.HasSwitch(switch3)); | 120 EXPECT_TRUE(cl.HasSwitch(switch3)); |
121 EXPECT_EQ(value3, cl.GetSwitchValue(switch3)); | 121 EXPECT_EQ(value3, cl.GetSwitchValue(switch3)); |
122 EXPECT_TRUE(cl.HasSwitch(switch4)); | 122 EXPECT_TRUE(cl.HasSwitch(switch4)); |
123 EXPECT_EQ(value4, cl.GetSwitchValue(switch4)); | 123 EXPECT_EQ(value4, cl.GetSwitchValue(switch4)); |
124 } | 124 } |
OLD | NEW |